summaryrefslogtreecommitdiff
path: root/tools/dumpconfig.c
diff options
context:
space:
mode:
authorPeter Rajnoha <prajnoha@redhat.com>2022-08-16 16:56:06 +0200
committerPeter Rajnoha <prajnoha@redhat.com>2022-08-17 10:47:24 +0200
commitb4cc28c2ef72ee022c1a03819927e31775c18676 (patch)
tree2d027a817b5a26e53ce32e97dd8cdb9f835568af /tools/dumpconfig.c
parent81839cc4ebf566ea9f3e6d819c7338b98cdec374 (diff)
downloadlvm2-b4cc28c2ef72ee022c1a03819927e31775c18676.tar.gz
lvmconfig: add --valuesonly option
The new --valuesonly option causes the lvmconfig output to contain only values without keys for each config node. This is practical mainly in case where we use lvmconfig in scripts and we want to assign the value to a different custom key or simply output the value itself without the key. For example: # lvmconfig --type full activation/raid_fault_policy raid_fault_policy="warn" # lvmconfig --type full activation/raid_fault_policy --valuesonly "warn" # my_var=$(lvmconfig --type full activation/raid_fault_policy --valuesonly) # echo $my_var "warn"
Diffstat (limited to 'tools/dumpconfig.c')
-rw-r--r--tools/dumpconfig.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/tools/dumpconfig.c b/tools/dumpconfig.c
index 9e4408e16..4a0f193c4 100644
--- a/tools/dumpconfig.c
+++ b/tools/dumpconfig.c
@@ -242,6 +242,10 @@ int dumpconfig(struct cmd_context *cmd, int argc, char **argv)
log_error("--withgeneralpreamble has no effect with --type list");
return EINVALID_CMD_LINE;
}
+ if (arg_is_set(cmd, valuesonly_ARG)) {
+ log_err("--valuesonly has no effect with --type list");
+ return EINVALID_CMD_LINE;
+ }
/* list type does not require status check */
} else if (!strcmp(type, "full")) {
tree_spec.type = CFG_DEF_TREE_FULL;
@@ -320,6 +324,9 @@ int dumpconfig(struct cmd_context *cmd, int argc, char **argv)
if (arg_is_set(cmd, withspaces_ARG))
tree_spec.withspaces = 1;
+ if (arg_is_set(cmd, valuesonly_ARG))
+ tree_spec.valuesonly = 1;
+
if (cft_check_handle)
tree_spec.check_status = cft_check_handle->status;