btrfs-progs: replace struct cmd_group->hidden with flags

We're also going to want to support aliases, so rather than adding
another member, replace "hidden" with a "flags" member.

Signed-off-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
This commit is contained in:
Omar Sandoval 2015-06-24 09:09:16 -07:00 committed by David Sterba
parent d26edf000c
commit 12aba72aed
3 changed files with 10 additions and 6 deletions

View file

@ -1382,7 +1382,7 @@ const struct cmd_group filesystem_cmd_group = {
{ "show", cmd_show, cmd_show_usage, NULL, 0 },
{ "sync", cmd_sync, cmd_sync_usage, NULL, 0 },
{ "defragment", cmd_defrag, cmd_defrag_usage, NULL, 0 },
{ "balance", cmd_balance, NULL, &balance_cmd_group, 1 },
{ "balance", cmd_balance, NULL, &balance_cmd_group, CMD_HIDDEN },
{ "resize", cmd_resize, cmd_resize_usage, NULL, 0 },
{ "label", cmd_label, cmd_label_usage, NULL, 0 },
{ "usage", cmd_filesystem_usage,

View file

@ -17,6 +17,10 @@
#ifndef __BTRFS_COMMANDS_H__
#define __BTRFS_COMMANDS_H__
enum {
CMD_HIDDEN = (1 << 0), /* should not be in help listings */
};
struct cmd_struct {
const char *token;
int (*fn)(int, char **);
@ -47,8 +51,8 @@ struct cmd_struct {
/* should be NULL if token is not a subgroup */
const struct cmd_group *next;
/* if true don't list this token in help listings */
int hidden;
/* CMD_* flags above */
int flags;
};
#define NULL_CMD_STRUCT {NULL, NULL, NULL, NULL, 0}

6
help.c
View file

@ -131,7 +131,7 @@ static void usage_command_group_internal(const struct cmd_group *grp, int full,
int do_sep = 0;
for (; cmd->token; cmd++) {
if (cmd->hidden)
if (cmd->flags & CMD_HIDDEN)
continue;
if (full && cmd != grp->commands)
@ -176,7 +176,7 @@ void usage_command_group_short(const struct cmd_group *grp)
fprintf(outf, "Command groups:\n");
for (cmd = grp->commands; cmd->token; cmd++) {
if (cmd->hidden)
if (cmd->flags & CMD_HIDDEN)
continue;
if (!cmd->next)
@ -187,7 +187,7 @@ void usage_command_group_short(const struct cmd_group *grp)
fprintf(outf, "\nCommands:\n");
for (cmd = grp->commands; cmd->token; cmd++) {
if (cmd->hidden)
if (cmd->flags & CMD_HIDDEN)
continue;
if (cmd->next)