mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-03 05:18:29 +03:00
commands: adjust syntax error message
This commit is contained in:
parent
b76852bf35
commit
8df3f300ba
@ -1597,7 +1597,7 @@ static void print_usage_def(struct arg_def *def)
|
|||||||
printf(" ...");
|
printf(" ...");
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_usage(struct command *cmd, int longhelp)
|
void print_usage(struct command *cmd, int longhelp, int desc_first)
|
||||||
{
|
{
|
||||||
struct command_name *cname = find_command_name(cmd->name);
|
struct command_name *cname = find_command_name(cmd->name);
|
||||||
int onereq = (cmd->cmd_flags & CMD_FLAG_ONE_REQUIRED_OPT) ? 1 : 0;
|
int onereq = (cmd->cmd_flags & CMD_FLAG_ONE_REQUIRED_OPT) ? 1 : 0;
|
||||||
@ -1609,7 +1609,7 @@ void print_usage(struct command *cmd, int longhelp)
|
|||||||
*/
|
*/
|
||||||
factor_common_options();
|
factor_common_options();
|
||||||
|
|
||||||
if (cmd->desc)
|
if (desc_first && cmd->desc)
|
||||||
_print_usage_description(cmd);
|
_print_usage_description(cmd);
|
||||||
|
|
||||||
printf(" %s", cmd->name);
|
printf(" %s", cmd->name);
|
||||||
@ -1709,7 +1709,12 @@ void print_usage(struct command *cmd, int longhelp)
|
|||||||
|
|
||||||
printf(" ]");
|
printf(" ]");
|
||||||
done:
|
done:
|
||||||
printf("\n\n");
|
printf("\n");
|
||||||
|
|
||||||
|
if (!desc_first && cmd->desc)
|
||||||
|
_print_usage_description(cmd);
|
||||||
|
|
||||||
|
printf("\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,7 +213,7 @@ struct command {
|
|||||||
|
|
||||||
int define_commands(char *run_name);
|
int define_commands(char *run_name);
|
||||||
int command_id_to_enum(const char *str);
|
int command_id_to_enum(const char *str);
|
||||||
void print_usage(struct command *cmd, int longhelp);
|
void print_usage(struct command *cmd, int longhelp, int desc_first);
|
||||||
void print_usage_common_cmd(struct command_name *cname, struct command *cmd);
|
void print_usage_common_cmd(struct command_name *cname, struct command *cmd);
|
||||||
void print_usage_common_lvm(struct command_name *cname, struct command *cmd);
|
void print_usage_common_lvm(struct command_name *cname, struct command *cmd);
|
||||||
void factor_common_options(void);
|
void factor_common_options(void);
|
||||||
|
@ -1560,11 +1560,10 @@ static struct command *_find_command(struct cmd_context *cmd, const char *path,
|
|||||||
|
|
||||||
if (!best_required) {
|
if (!best_required) {
|
||||||
/* cmd did not have all the required opt/pos args of any command */
|
/* cmd did not have all the required opt/pos args of any command */
|
||||||
log_error("Failed to find a matching command definition.");
|
log_error("Incorrect syntax. Run '%s --help' for more information.", name);
|
||||||
log_error("Run '%s --help' for more information.", name);
|
|
||||||
if (close_ro) {
|
if (close_ro) {
|
||||||
log_warn("Closest command usage is:");
|
log_warn("Nearest similar command has syntax:");
|
||||||
print_usage(&_cmdline.commands[close_i], 0);
|
print_usage(&_cmdline.commands[close_i], 0, 0);
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -1711,7 +1710,7 @@ static int _usage(const char *name, int longhelp)
|
|||||||
if ((_cmdline.commands[i].cmd_flags & CMD_FLAG_SECONDARY_SYNTAX) && !longhelp)
|
if ((_cmdline.commands[i].cmd_flags & CMD_FLAG_SECONDARY_SYNTAX) && !longhelp)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
print_usage(&_cmdline.commands[i], longhelp);
|
print_usage(&_cmdline.commands[i], longhelp, 1);
|
||||||
cmd = &_cmdline.commands[i];
|
cmd = &_cmdline.commands[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user