Skip to content

cli: pass -h/--help to subcommands instead of intercepting in main parser #191

Open

Description

Problem

The qcom-ptool CLI dispatcher intercepts -h and --help flags even when a subcommand is specified (e.g. qcom-ptool gen_partition -h or qcom-ptool gen_udev_rules -h), printing the top-level CLI help instead of delegating to the subcommand's help handler.

This contradicts the top-level help message epilog and README which state:
Run 'qcom-ptool <subcommand> -h' to see the options accepted by each subcommand.

Additionally, show.py fails with getopt.GetoptError: option -h not recognized because -h/--help is not handled in its options list.

Current Behavior

Running qcom-ptool <subcommand> -h or qcom-ptool <subcommand> --help prints the top-level qcom-ptool help:

usage: qcom-ptool [-h] [-V] subcommand

Qualcomm partition tool - GPT partition table generator and mass storage
programmer.
...
Run 'qcom-ptool <subcommand> -h' to see the options accepted by each
subcommand.

The subcommand is never invoked and its options/usage cannot be viewed.

Expected Behavior

When a valid subcommand is given, flags such as -h and --help should be passed to that subcommand so the user can inspect the options accepted by each subcommand.

Reproduction

Run:
qcom-ptool gen_udev_rules -h or qcom-ptool gen_partition -h
Observe that the top-level qcom-ptool help is displayed instead of the subcommand usage.

Technical Context

In qcom_ptool/cli.py, _build_parser() creates an argparse.ArgumentParser with default add_help=True. When parser.parse_known_args() runs on ["gen_udev_rules", "-h"], argparse intercepts -h, prints the top-level help, and terminates immediately before runpy.run_module can be called.
In qcom_ptool/show.py, getopt.getopt() only accepts ["board=", "hlos=", "boot-fw=", "root="] and does not accept -h / --help.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions