Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add output flag for services #9

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions src/k16/kl/commands/services.clj
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,14 @@

(log/info (str "@|green Service default-endpoint has been updated |@"))))

(defn- list-services [props]
(defn- list-service-list [services]
(doseq [service services]
(println (:name service))))

(defn- list-service-table [services]
(pprint/print-table [:name :default-endpoint] services))

(defn list-services [props]
(let [module-name (prompt.config/get-module-name props)

{:keys [modules]} (api.resolver/pull! module-name {})
Expand All @@ -67,7 +74,9 @@
(map (fn [[service-name service]]
(merge service {:name (name service-name)}))))]

(pprint/print-table [:name :default-endpoint] services)))
(case (:output props)
"names" (list-service-list services)
"table" (list-service-table services))))

(def cmd
{:command "services"
Expand All @@ -76,7 +85,11 @@
:subcommands [{:command "list"
:description "List all services"

:opts [{:option "module"
:opts [{:option "output"
:short "o"
:default "table"
:type :string},
{:option "module"
:short "m"
:type :string}]

Expand Down
Loading