Skip to content

Commit

Permalink
Allow setting service and endpoint as arguments for set-endpoint comm…
Browse files Browse the repository at this point in the history
…and (#4)
  • Loading branch information
nikolubbe authored Jan 19, 2024
1 parent 4719d87 commit b69d7f5
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 b69d7f5

Please sign in to comment.