Skip to contentSkip to conversation

master - commands: adjust default help output

PATCH David Teigland 1 participant 1 message Feb 21, 2017

lore
Share & tools
lore
#0 lore raw
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=21fc35dd1bcd068ad4453e5c18b2d754bdcb12b0
Commit:        21fc35dd1bcd068ad4453e5c18b2d754bdcb12b0
Parent:        7e411b111f4d87a1f342a016299fe90c2d64ec2d
Author:        David Teigland <[email protected]>
AuthorDate:    Tue Feb 21 11:40:51 2017 -0600
Committer:     David Teigland <[email protected]>
CommitterDate: Tue Feb 21 12:27:51 2017 -0600

commands: adjust default help output

Remove the "usage notes" which should just live in the man pages.

When there are 3 or more variants of a command, print all the options produces a lot of output, so require --longhelp to print all the options in these cases.

---
 tools/command.c    |    7 ++++-
 tools/command.h    |    3 +-
 tools/lvmcmdline.c |   54 +++++++++++++++------------------------------------
 3 files changed, 23 insertions(+), 41 deletions(-)
tools/command.c +5 -2
index fe8c1f6..c425fd1 100644
@@ -1229,7 +1229,7 @@ static int is_lvm_all_opt(int opt)
 
 /* Find common options for all variants of each command name. */
 
-static void factor_common_options(void)
+void factor_common_options(void)
 {
 	int cn, opt_enum, ci, oo, ro, found;
 	struct command *cmd;
@@ -1602,7 +1602,7 @@ static void print_usage_def(struct arg_def *def)
 		printf(" ...");
 }
 
-void print_usage(struct command *cmd)
+void print_usage(struct command *cmd, int longhelp)
 {
 	struct command_name *cname = find_command_name(cmd->name);
 	int onereq = (cmd->cmd_flags & CMD_FLAG_ONE_REQUIRED_OPT) ? 1 : 0;
@@ -1652,6 +1652,9 @@ void print_usage(struct command *cmd)
 		}
 	}
 
+	if (!longhelp)
+		goto done;
+
 	if (!cmd->oo_count)
 		goto op_count;
 
tools/command.h +2 -1
index 2d8f628..51c4551 100644
@@ -213,7 +213,8 @@ struct command {
 
 int define_commands(char *run_name);
 int command_id_to_enum(const char *str);
-void print_usage(struct command *cmd);
+void print_usage(struct command *cmd, int longhelp);
 void print_usage_common(struct command_name *cname, struct command *cmd);
+void factor_common_options(void);
 
 #endif
tools/lvmcmdline.c +16 -38

85 lines not on this page · raw message