Skip to content

Commit

Permalink
add output flag for services
Browse files Browse the repository at this point in the history
  • Loading branch information
nikolubbe committed Jul 24, 2024
1 parent 26df3aa commit 2646094
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 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 0
:type :string}]

Expand All @@ -86,13 +99,13 @@
:description "Set the default endpoint for a service"

:opts [{:option "module"
:short 0
:short "m"
:type :string}
{:option "service"
:short 1
:short 0
:type :string}
{:option "endpoint"
:short 2
:short 1
:type :string}]

:runs set-default-service-endpoint!}]})

0 comments on commit 2646094

Please sign in to comment.