kdave / btrfs-progs

Development of userspace BTRFS tools
GNU General Public License v2.0
563 stars 243 forks source link

bug: `unrecognized option '--help'` #889

Open major0 opened 1 month ago

major0 commented 1 month ago

Various sub-commands to btrfs claim --help is an unrecognized option if there are any other options on the CLI.

Examples of --help being unrecognized.

btrfs filesystem defragment -v --help
btrfs filesystem defragment: unrecognized option '--help'
Try 'btrfs filesystem defragment --help' for more information
btrfs balance start -v --help
btrfs balabtrfs balance start -v --help
btrfs balance start: unrecognized option '--help'
Try 'btrfs balance start --help' for more information

Alternatively, some sub-commands support --help even if there are extra options on the CLI:

btrfs filesystem df -v --help
usage: btrfs filesystem df [options] <path>

    Show space usage information for a mount point

    -b|--raw                  raw numbers in bytes 
    -h|--human-readable       human friendly numbers, base 1024 (default) 
    -H                        human friendly numbers, base 1000 
    --iec                     use 1024 as a base (KiB, MiB, GiB, TiB) 
    --si                      use 1000 as a base (kB, MB, GB, TB) 
    -k|--kbytes               show sizes in KiB, or kB with --si 
    -m|--mbytes               show sizes in MiB, or MB with --si 
    -g|--gbytes               show sizes in GiB, or GB with --si 
    -t|--tbytes               show sizes in TiB, or TB with --si 

    Global options:
    --format TYPE             where TYPE is: text
kdave commented 1 month ago

It seems to also depend on the order, because btrfs fi defrat --help -v works

kdave commented 1 month ago

handle_help_options_next_level() checks only the first argument if it's --help.