|
1 | 1 | (ns k16.kl.commands.services
|
2 | 2 | (:require
|
| 3 | + [cli-matic.utils :as cli.utils] |
3 | 4 | [clojure.pprint :as pprint]
|
4 | 5 | [k16.kl.api.module :as api.module]
|
5 | 6 | [k16.kl.api.proxy :as api.proxy]
|
6 | 7 | [k16.kl.api.resolver :as api.resolver]
|
7 | 8 | [k16.kl.api.state :as api.state]
|
| 9 | + [k16.kl.prompt :as prompt] |
8 | 10 | [k16.kl.prompt.config :as prompt.config]
|
9 |
| - [meta-merge.core :as metamerge] |
10 |
| - [pretty.cli.prompt :as prompt])) |
| 11 | + [meta-merge.core :as metamerge])) |
11 | 12 |
|
12 | 13 | (defn- set-default-service-endpoint! [props]
|
13 | 14 | (let [module-name (prompt.config/get-module-name props)
|
|
18 | 19 | state (api.state/get-state module-name)
|
19 | 20 |
|
20 | 21 | service-name
|
21 |
| - (-> (prompt/list-select "Select Service" |
22 |
| - (->> (get-in module [:network :services]) |
23 |
| - (map (fn [[service-name]] |
24 |
| - {:value (name service-name) |
25 |
| - :label (name service-name)})))) |
| 22 | + (-> (prompt/select "Select Service" |
| 23 | + (->> (get-in module [:network :services]) |
| 24 | + (map (fn [[service-name]] |
| 25 | + {:value (name service-name) |
| 26 | + :label (name service-name)})))) |
26 | 27 | keyword)
|
27 | 28 |
|
| 29 | + _ (when-not service-name (cli.utils/exit! "No service selected" 1)) |
| 30 | + |
28 | 31 | service (get-in module [:network :services service-name])
|
29 | 32 |
|
30 | 33 | endpoint-name
|
31 |
| - (-> (prompt/list-select "Select Default Endpoint" |
32 |
| - (->> (:endpoints service) |
33 |
| - (map (fn [[endpoint-name]] |
34 |
| - {:value (name endpoint-name) |
35 |
| - :label (name endpoint-name)})))) |
| 34 | + (-> (prompt/select "Select Default Endpoint" |
| 35 | + (->> (:endpoints service) |
| 36 | + (map (fn [[endpoint-name]] |
| 37 | + {:value (name endpoint-name) |
| 38 | + :label (name endpoint-name)})))) |
36 | 39 | keyword)
|
37 | 40 |
|
| 41 | + _ (when-not endpoint-name (cli.utils/exit! "No endpoint selected" 1)) |
| 42 | + |
38 | 43 | updated-state
|
39 | 44 | (assoc-in state [:network :services service-name :default-endpoint]
|
40 | 45 | endpoint-name)]
|
|
0 commit comments