Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: unrecognized option '--help' #889

Open
major0 opened this issue Sep 11, 2024 · 3 comments
Open

bug: unrecognized option '--help' #889

major0 opened this issue Sep 11, 2024 · 3 comments
Labels
Milestone

Comments

@major0
Copy link

major0 commented Sep 11, 2024

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
@major0 major0 changed the title bug: unrecognied option '--help' bug: unrecognized option '--help' Sep 11, 2024
@kdave kdave added the bug label Sep 12, 2024
@kdave
Copy link
Owner

kdave commented Sep 17, 2024

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

@kdave
Copy link
Owner

kdave commented Sep 17, 2024

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

@kdave
Copy link
Owner

kdave commented Jan 28, 2025

The best fix seems to be to properly detect the unrecognized options, in this case it's -v for filesystem df, no matter if --help is there or not. Getting output of --help will now also work if there's a known option.

$ btrfs fi df -v --help /
btrfs filesystem df: invalid option 'v'
Try 'btrfs filesystem df --help' for more information

$ btrfs fi df -H --help /
usage: btrfs filesystem df [options] <path>

    Show space usage information for a mount point

    -b|--raw                  raw numbers in byte
...

kdave added a commit that referenced this issue Jan 28, 2025
There's a report that handling of --help in connection with other option
is confusing in some cases:

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

Update clean_args_no_options() to detect unrecognized options properly
and do not show full help text (which usued to be done in the past but
is confusing and not pointing to the problem).

There's also a mixup of global verbosity options and command-specific
verbosity options (now deprecated), so in some commands they are
recognized.

Also handle the --help option for commands without options so the
following works:

  $ btrfs fi df -v --help /
  btrfs filesystem df: invalid option 'v'
  Try 'btrfs filesystem df --help' for more information

  $ btrfs fi df -H --help /
  usage: btrfs filesystem df [options] <path>

      Show space usage information for a mount point

      -b|--raw                  raw numbers in byte
  ...

Issue: #889
Signed-off-by: David Sterba <[email protected]>
@kdave kdave added this to the v6.13 milestone Jan 28, 2025
kdave added a commit that referenced this issue Jan 28, 2025
There's a report that handling of --help in connection with other option
is confusing in some cases:

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

Update clean_args_no_options() to detect unrecognized options properly
and do not show full help text (which usued to be done in the past but
is confusing and not pointing to the problem).

There's also a mixup of global verbosity options and command-specific
verbosity options (now deprecated), so in some commands they are
recognized.

Also handle the --help option for commands without options so the
following works:

  $ btrfs fi df -v --help /
  btrfs filesystem df: invalid option 'v'
  Try 'btrfs filesystem df --help' for more information

  $ btrfs fi df -H --help /
  usage: btrfs filesystem df [options] <path>

      Show space usage information for a mount point

      -b|--raw                  raw numbers in byte
  ...

Issue: #889
Signed-off-by: David Sterba <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants