Skip to content

Commit b69d7f5

Browse files
authored
Allow setting service and endpoint as arguments for set-endpoint command (#4)
1 parent 4719d87 commit b69d7f5

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

src/k16/kl/commands/services.clj

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,27 @@
2020
state (api.state/get-state module-name)
2121

2222
service-name
23-
(-> (prompt/select "Select Service"
24-
(->> (get-in module [:network :services])
25-
(map (fn [[service-name]]
26-
{:value (name service-name)
27-
:label (name service-name)}))))
28-
keyword)
23+
(or (-> props :service keyword)
24+
(-> (prompt/select "Select Service"
25+
(->> (get-in module [:network :services])
26+
(map (fn [[service-name]]
27+
{:value (name service-name)
28+
:label (name service-name)}))))
29+
keyword))
2930

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

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

3536
endpoint-name
36-
(-> (prompt/select "Select Default Endpoint"
37-
(->> (:endpoints service)
38-
(map (fn [[endpoint-name]]
39-
{:value (name endpoint-name)
40-
:label (name endpoint-name)}))))
41-
keyword)
37+
(or (-> props :endpoint :keyword)
38+
(-> (prompt/select "Select Default Endpoint"
39+
(->> (:endpoints service)
40+
(map (fn [[endpoint-name]]
41+
{:value (name endpoint-name)
42+
:label (name endpoint-name)}))))
43+
keyword))
4244

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

8688
:opts [{:option "module"
8789
:short 0
90+
:type :string}
91+
{:option "service"
92+
:short 1
93+
:type :string}
94+
{:option "endpoint"
95+
:short 2
8896
:type :string}]
8997

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

0 commit comments

Comments
 (0)