]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
plugins: introduce OPT_FLAG_JSON for command option json
authorTokunori Ikegami <ikegami.t@gmail.com>
Fri, 20 Dec 2024 15:23:08 +0000 (00:23 +0900)
committerDaniel Wagner <wagi@monom.org>
Fri, 20 Dec 2024 16:53:17 +0000 (17:53 +0100)
This is to not need ugly ifdefs everywhere.

Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
plugins/dapustor/dapustor-nvme.c
plugins/intel/intel-nvme.c
plugins/scaleflux/sfx-nvme.c
plugins/ssstc/ssstc-nvme.c
util/argconfig.h

index b86f9ab4a9813533c934d82f25b2207aeb2bcc2d..8dc12d553e840a2f481c7dd9dff3e15ca6c834df 100644 (file)
@@ -532,9 +532,7 @@ static int dapustor_additional_smart_log(int argc, char **argv, struct command *
        OPT_ARGS(opts) = {
                OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace),
                OPT_FLAG("raw-binary",   'b', &cfg.raw_binary,   raw),
-#ifdef CONFIG_JSONC
-               OPT_FLAG("json",         'j', &cfg.json,         json),
-#endif /* CONFIG_JSONC */
+               OPT_FLAG_JSON("json",    'j', &cfg.json,         json),
                OPT_END()
        };
 
index 9014d198c396dedebedbfbc57c6d3d645f343c52..e5c896c2c3ba20b758725105c3e6f6dab4678ae1 100644 (file)
@@ -365,9 +365,7 @@ static int get_additional_smart_log(int argc, char **argv, struct command *cmd,
        OPT_ARGS(opts) = {
                OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace),
                OPT_FLAG("raw-binary",   'b', &cfg.raw_binary,   raw),
-#ifdef CONFIG_JSONC
-               OPT_FLAG("json",         'j', &cfg.json,         json),
-#endif /* CONFIG_JSONC */
+               OPT_FLAG_JSON("json",    'j', &cfg.json,         json),
                OPT_END()
        };
 
@@ -1069,9 +1067,7 @@ static int get_lat_stats_log(int argc, char **argv, struct command *cmd, struct
        OPT_ARGS(opts) = {
                OPT_FLAG("write",       'w', &cfg.write,        write),
                OPT_FLAG("raw-binary",  'b', &cfg.raw_binary,   raw),
-#ifdef CONFIG_JSONC
-               OPT_FLAG("json",        'j', &cfg.json,         json),
-#endif /* CONFIG_JSONC */
+               OPT_FLAG_JSON("json",   'j', &cfg.json,         json),
                OPT_END()
        };
 
index f6bcad01a9146c273e8973376fb6c93e70a95374..9363d93fde50bdafb049a291e31bb1ecb00344e2 100644 (file)
@@ -344,7 +344,7 @@ static int get_additional_smart_log(int argc, char **argv, struct command *cmd,
        OPT_ARGS(opts) = {
                OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace),
                OPT_FLAG("raw-binary",   'b', &cfg.raw_binary,   raw),
-               OPT_FLAG("json",                 'j', &cfg.json,                 json),
+               OPT_FLAG_JSON("json",    'j', &cfg.json,         json),
                OPT_END()
        };
 
index 302df988073294da1482c645ccd8aa408a1e8d7f..5cbc8f96a35e95914c98422792d0a3c54e914ada 100644 (file)
@@ -402,7 +402,7 @@ int ssstc_get_add_smart_log(int argc, char **argv, struct command *cmd, struct p
        OPT_ARGS(opts) = {
                OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace),
                OPT_FLAG("raw-binary",   'b', &cfg.raw_binary,   raw),
-               OPT_FLAG("json",         'j', &cfg.json,         json),
+               OPT_FLAG_JSON("json",    'j', &cfg.json,         json),
                OPT_END()
        };
 
index 3dff25a3273713a26e07edb2bfd15b3314bffadc..44d2e4e6ab13b9387a6e65dbbff1e8ae6abe187c 100644 (file)
@@ -96,6 +96,12 @@ enum argconfig_types {
 #define OPT_LIST(l, s, v, d, ...) OPT_STRING(l, s, "LIST", v, d, __VA_ARGS__)
 #define OPT_STR(l, s, v, d, ...) OPT_STRING(l, s, "STRING", v, d, __VA_ARGS__)
 
+#ifdef CONFIG_JSONC
+#define OPT_FLAG_JSON(l, s, v, d, ...) OPT_FLAG(l, s, v, d, __VA_ARGS__)
+#else /* CONFIG_JSONC */
+#define OPT_FLAG_JSON(l, s, v, d, ...) OPT_END()
+#endif /* CONFIG_JSONC */
+
 #define OPT_VALS(n) \
        struct argconfig_opt_val n[]