|
18 | 18 | %%
|
19 | 19 | %% -------------------------------------------------------------------
|
20 | 20 | -module(clique_config).
|
| 21 | +-include("clique_specs.hrl"). |
21 | 22 |
|
22 | 23 | %% API
|
23 | 24 | -export([init/0,
|
|
43 | 44 | -type err() :: {error, term()}.
|
44 | 45 | -type status() :: clique_status:status().
|
45 | 46 | -type proplist() :: [{atom(), term()}].
|
46 |
| --type flags() :: [{atom() | char(), term()}]. |
| 47 | +-type flagspecs() :: [spec()]. |
| 48 | +-type flags() :: proplist(). |
| 49 | +-type args() :: clique_parser:args(). |
47 | 50 |
|
48 | 51 | -type envkey() :: {string(), {atom(), atom()}}.
|
49 | 52 | -type cuttlefish_flag_spec() :: {flag, atom(), atom()}.
|
@@ -238,15 +241,15 @@ run_callback({Args, Flags, Status}) ->
|
238 | 241 | Status.
|
239 | 242 |
|
240 | 243 | -spec get_config(err()) -> err();
|
241 |
| - ({proplist(), flags()}) -> |
| 244 | + ({args(), flags()}) -> |
242 | 245 | {proplist(), proplist(), flags()} | err().
|
243 | 246 | get_config({error, _}=E) ->
|
244 | 247 | E;
|
245 | 248 | get_config({[], _Flags}) ->
|
246 | 249 | {error, set_no_args};
|
247 | 250 | get_config({Args, Flags}) ->
|
248 | 251 | [{schema, Schema}] = ets:lookup(?schema_table, schema),
|
249 |
| - Conf = [{cuttlefish_variable:tokenize(atom_to_list(K)), V} || {K, V} <- Args], |
| 252 | + Conf = [{cuttlefish_variable:tokenize(K), V} || {K, V} <- Args], |
250 | 253 | case cuttlefish_generator:minimal_map(Schema, Conf) of
|
251 | 254 | {error, _, Msg} ->
|
252 | 255 | {error, {invalid_config, Msg}};
|
@@ -326,18 +329,18 @@ set_remote_app_config(AppConfig) ->
|
326 | 329 | [clique_status:alert([clique_status:text(Alert)])]
|
327 | 330 | end.
|
328 | 331 |
|
329 |
| --spec config_flags() -> flags(). |
| 332 | +-spec config_flags() -> flagspecs(). |
330 | 333 | config_flags() ->
|
331 |
| - [{node, [{shortname, "n"}, |
332 |
| - {longname, "node"}, |
333 |
| - {typecast, fun clique_typecast:to_node/1}, |
334 |
| - {description, |
335 |
| - "The node to apply the operation on"}]}, |
336 |
| - |
337 |
| - {all, [{shortname, "a"}, |
338 |
| - {longname, "all"}, |
339 |
| - {description, |
340 |
| - "Apply the operation to all nodes in the cluster"}]}]. |
| 334 | + [clique_spec:make({node, [{shortname, "n"}, |
| 335 | + {longname, "node"}, |
| 336 | + {typecast, fun clique_typecast:to_node/1}, |
| 337 | + {description, |
| 338 | + "The node to apply the operation on"}]}), |
| 339 | + |
| 340 | + clique_spec:make({all, [{shortname, "a"}, |
| 341 | + {longname, "all"}, |
| 342 | + {description, |
| 343 | + "Apply the operation to all nodes in the cluster"}]})]. |
341 | 344 |
|
342 | 345 |
|
343 | 346 | -spec get_valid_mappings([string()]) -> err() | [{string(), cuttlefish_mapping:mapping()}].
|
|
0 commit comments