Commit Graph

23 Commits

Author SHA1 Message Date
Nikolay Borisov cfa470d5a6 btrfs-progs: Remove get_argv0_buf
get_argv0_buf is used only in two functions in help.c which also has
direct access to the static argv0_buf. All other references to this
buffer are direct. So remove the function. No functional changes.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2019-03-11 15:30:33 +01:00
David Sterba c9b60c9087 btrfs-progs: help: update messages of argc constraint checkers
The messages should be more specific about how many arguments are
actuall expected.

Signed-off-by: David Sterba <dsterba@suse.com>
2019-03-05 12:57:55 +01:00
David Sterba 309719fb97 btrfs-progs: help: add helper for unrecognized option error message
Currently any unrecognized option does not print very usable message and
only dumps the whole help. Other common utilities (eg. from the
util-linux suite) print a short message and point to help. And we're
going to do the same.

Example:

  $ btrfs device add --unknown device path
  btrfs device add: unrecognized option '--unknown'
  Try 'btrfs device add --help' for more information

Signed-off-by: David Sterba <dsterba@suse.com>
2019-03-05 12:57:55 +01:00
Josh Soref b1d39a42a4 btrfs-progs: fix typos in comments
Generated by https://github.com/jsoref/spelling

Issue: #154
Author: Josh Soref <jsoref@users.noreply.github.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-11-26 18:24:48 +01:00
Gu Jinxiang 50417091a0 btrfs-progs: Remove unused parameter
Parameter usagestr is not used, remove it.

Signed-off-by: Gu Jinxiang <gujx@cn.fujitsu.com>
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-03-30 22:15:55 +02:00
David Sterba c56d61883c btrfs-progs: help: print multiple syntax schemas on separate lines
The help string for some commands could be split to more lines for
clarity, eg. as is now in the receive command. The 'btrfs help' listing
should indent all the lines properly, similar the command specific
help with "usage:'.

The syntax of the first help string line is to separate all command
usage schemas by "\n".

Signed-off-by: David Sterba <dsterba@suse.com>
2017-11-14 15:59:00 +01:00
David Sterba 628307f5c4 btrfs-progs: updated and add missing function attributes to the definition
Reported by sparse. Make the prototype match the definition and put the
attributes before the function.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-25 15:18:32 +02:00
David Sterba 1ffcc9b455 btrfs-progs: move prefixcmp helper to utils
Signed-off-by: David Sterba <dsterba@suse.com>
2017-03-08 13:00:47 +01:00
David Sterba a52537a594 btrfs-progs: move help implemetnation to own file
Signed-off-by: David Sterba <dsterba@suse.com>
2017-03-08 13:00:45 +01:00
David Sterba 1c880f34f1 btrfs-progs: move help defines to own header
Signed-off-by: David Sterba <dsterba@suse.com>
2017-03-08 13:00:45 +01:00
David Sterba c9d43f2f3d btrfs-progs: help: fix printing of aliased commands
The help string for aliased commands is glued on one line.  This
happened for device delete/remove.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-12-14 15:06:36 +01:00
David Sterba c26dc1ef33 btrfs-progs: move prefixcmp to utils
Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-14 11:07:10 +01:00
David Sterba e7d0a023ae btrfs-progs: no extra newline between aliased commands in help text
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-06-26 16:44:29 +02:00
Omar Sandoval f802f572b1 btrfs-progs: alias btrfs device delete to btrfs device remove
There's an awkward asymmetry between btrfs device add and btrfs device
delete. Resolve this by aliasing delete to remove.

Signed-off-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-06-26 16:33:39 +02:00
Omar Sandoval 12aba72aed 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>
2015-06-26 16:33:38 +02:00
David Sterba add9d7fe4b btrfs-progs: print compact help for btrfs
Running 'btrfs' without arguments will print complete help that spans
a lot of lines and is really helpful. Print only subcommand group
names with short descriptions, similar to what 'git' does.

Signed-off-by: David Sterba <dsterba@suse.cz>
2015-06-09 14:27:54 +02:00
David Sterba 54003d7ee6 btrfs-progs: fix argv0_buf handling
The variable argv0_buf was duplicated and the changes done in utils.c
were not propagated to help.c. So if an unknown commandline token was
found, the error message did not contain the known part:

 $ btrfs scrub test
 : unknown token 'test'

instead of

 $ btrfs scrub test
 btrfs scrub: uknown token 'test'

Signed-off-by: David Sterba <dsterba@suse.cz>
2015-06-09 13:32:32 +02:00
Merlijn Wajer c69854247b btrfs-progs: include headers required for musl-libc
This fixes various compilation errors where PATH_MAX and XATTR_SIZE_MAX
were missing. To my knowledge, this should have no bad side effects.

Signed-off-by: Merlijn Wajer <merlijn@wizzup.org>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-12-18 18:22:06 +01:00
Gui Hecheng a184abc70f btrfs-progs: move the check_argc_* functions into utils.c
To let the independent tools(e.g. btrfs-image, btrfs-convert, etc.)
share the convenience of check_argc_* functions, just move it into
utils.c.
Also add a new function "set_argv0" to set the correct tool name:
	*btrfs-image*: too few arguments

The original btrfs* tools work as before.

Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
[moved argv0 and check_argc to utils.*]
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-08-22 14:55:27 +02:00
Wang Shilong c1e23b2aa5 Btrfs-progs: return 1 rather than 129 in usage()
if usage or syntax error happens, we return 1.

Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
2013-10-16 08:20:03 -04:00
Zach Brown d1dc091980 btrfs-progs: make many private symbols static
Signed-off-by: Zach Brown <zab@redhat.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
2013-09-03 19:41:08 +02:00
Ilya Dryomov 08b51bd731 Btrfs-progs: allow multi-line command group synopsis
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
2012-02-08 18:55:51 +02:00
Ilya Dryomov 8b4e3d8b5b Btrfs-progs: implement new subcommand parser
This completely replaces the existing subcommand infrastructure, which
is not flexible enough to accomodate our needs.  Instead of a global
command table we now have per-level tables and command group handlers,
which allows command-group-specific handling of options and subcommands.
The new parser exports a clear interface and gets out of the way - all
control over how matching is done is passed to commands and command
group handlers.

One side effect of this is that command implementors have to check the
number of arguments themselves - patch to fix up all existing commands
follows.

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
2012-02-03 21:00:17 +02:00