Skip to content

Commit

Permalink
plugins: introduce OPT_FLAG_JSON for command option json
Browse files Browse the repository at this point in the history
This is to not need ugly ifdefs everywhere.

Signed-off-by: Tokunori Ikegami <[email protected]>
  • Loading branch information
ikegami-t authored and igaw committed Dec 20, 2024
1 parent c4a1e11 commit 936383f
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
4 changes: 1 addition & 3 deletions plugins/dapustor/dapustor-nvme.c
Original file line number Diff line number Diff line change
Expand Up @@ -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()
};

Expand Down
8 changes: 2 additions & 6 deletions plugins/intel/intel-nvme.c
Original file line number Diff line number Diff line change
Expand Up @@ -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()
};

Expand Down Expand Up @@ -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()
};

Expand Down
2 changes: 1 addition & 1 deletion plugins/scaleflux/sfx-nvme.c
Original file line number Diff line number Diff line change
Expand Up @@ -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()
};

Expand Down
2 changes: 1 addition & 1 deletion plugins/ssstc/ssstc-nvme.c
Original file line number Diff line number Diff line change
Expand Up @@ -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()
};

Expand Down
6 changes: 6 additions & 0 deletions util/argconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -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[]

Expand Down

0 comments on commit 936383f

Please sign in to comment.