Skip to content

Commit

Permalink
Allow setting service and endpoint as arguments for set-endpoint command
Browse files Browse the repository at this point in the history
  • Loading branch information
nikolubbe committed Jan 19, 2024
1 parent 4719d87 commit cbf9c8e
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions src/k16/kl/commands/services.clj
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,27 @@
state (api.state/get-state module-name)

service-name
(-> (prompt/select "Select Service"
(->> (get-in module [:network :services])
(map (fn [[service-name]]
{:value (name service-name)
:label (name service-name)}))))
keyword)
(or (-> props :service keyword)
(-> (prompt/select "Select Service"
(->> (get-in module [:network :services])
(map (fn [[service-name]]
{:value (name service-name)
:label (name service-name)}))))
keyword))

_ (when-not service-name (cli.utils/exit! "No service selected" 1))
_ (log/info (str "Using @|bold " (name service-name) "|@"))

service (get-in module [:network :services service-name])

endpoint-name
(-> (prompt/select "Select Default Endpoint"
(->> (:endpoints service)
(map (fn [[endpoint-name]]
{:value (name endpoint-name)
:label (name endpoint-name)}))))
keyword)
(or (-> props :endpoint :keyword)
(-> (prompt/select "Select Default Endpoint"
(->> (:endpoints service)
(map (fn [[endpoint-name]]
{:value (name endpoint-name)
:label (name endpoint-name)}))))
keyword))

_ (when-not endpoint-name (cli.utils/exit! "No endpoint selected" 1))
_ (log/info (str "Using @|bold " (name endpoint-name) "|@"))
Expand Down Expand Up @@ -85,6 +87,12 @@

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

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

0 comments on commit cbf9c8e

Please sign in to comment.