Skip to content

Commit 4b892f8

Browse files
committed
btrfs-progs: update help texts to better explain global options
There was a question in the mailing list regarding option --quiet and why it's not working as 'btrfs subvolume create --quiet ...'. Historically there were per-command verbosity options but this was unified under the global options with it's specific syntax. This is not uncommon and e.g. git also does have this option split. The documentation and help strings are not making this clear enough, so print syntax examples at the end of the help of 'btrfs', and do other adjustments. Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 663244e commit 4b892f8

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

Documentation/btrfs.rst

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ btrfs(8)
44
SYNOPSIS
55
--------
66

7-
**btrfs** [global] <group> [<group>...] <command> [<args>]
7+
**btrfs** [global options] <group> [<group>...] <command> [options] [<args>]
88

99
DESCRIPTION
1010
-----------
@@ -43,11 +43,17 @@ All numbers will be formatted according to the rules of the `C` locale
4343
(ignoring the shell locale, see :manref:`locale(7)`).
4444

4545
For an overview of a given command use :command:`btrfs command --help`
46-
or :command:`btrfs [command...] --help --full` to print all available options.
46+
or :command:`btrfs [command...] help --full` to print all available options
47+
for all commands.
4748

4849
There are global options that are passed between *btrfs* and the *group* name
4950
and affect behaviour not specific to the command, e.g. verbosity or the type
50-
of the output.
51+
of the output:
52+
53+
.. code-block:: bash
54+
55+
btrfs -q subvolume create ...
56+
btrfs --dry-run subvolume create ...
5157
5258
--format <format>
5359
if supported by the command, print subcommand output in that format (text, json)

btrfs.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ static const char * const btrfs_cmd_group_usage[] = {
3737
* The main command group is the only one that takes options so this
3838
* needs the newlines and manual formatting.
3939
*/
40-
"btrfs [global] <group> [<group>...] <command> [<args>]\n"
40+
"btrfs [global options] <group> [<group>...] <command> [options] [<args>]\n"
4141
"\n"
4242
"Global options:\n"
4343
" --format <format> if supported, print subcommand output in that format (text, json)\n"
@@ -48,12 +48,19 @@ static const char * const btrfs_cmd_group_usage[] = {
4848
"\n"
4949
"Options for the main command only:\n"
5050
" --help print condensed help for all subcommands\n"
51-
" --version print version string",
51+
" --version print version string and built-in features",
5252
NULL
5353
};
5454

5555
static const char btrfs_cmd_group_info[] =
56-
"Use --help as an argument for information on a specific group or command.";
56+
"Use --help as an option for information about a group or command:\n"
57+
" btrfs subvolume --help\n"
58+
" btrfs subvolume create --help\n"
59+
"\n"
60+
"Global options like -q/-v must follow the tool name 'btrfs':\n"
61+
" btrfs -q subvolume create ...\n"
62+
" btrfs --dry-run subvolume create ..."
63+
;
5764

5865
static inline const char *skip_prefix(const char *str, const char *prefix)
5966
{
@@ -363,7 +370,6 @@ static void handle_special_globals(int shift, int argc, char **argv)
363370
usage_command_group(&btrfs_cmd_group, true, false);
364371
else
365372
cmd_execute(&cmd_struct_help, argc, argv);
366-
print_output_formats(stdout);
367373
exit(0);
368374
}
369375

0 commit comments

Comments
 (0)