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

Use only the base name of the program in argparse help #14

Merged
merged 2 commits into from
Jun 13, 2024

Conversation

cottsay
Copy link
Member

@cottsay cottsay commented Jun 6, 2024

Showing the "full" program name where appropriate in some parts of the help output is useful, but in this context, we're really referring more to the program's title in a more abstract sense. Since we don't want to re-invoke colcon_core.command.get_prog_name, we can narrow our current use of the argparse reported prog to only the basename which will usually give us exactly what we want.

Example of where the full path was harming the help text experience:

usage: C:\Program Files\Python312\Scripts\colcon [-h] [--log-base LOG_BASE] [--log-level LOG_LEVEL]
                                                 {alias,build,extension-points,extensions,graph,info,list,metadata,mixin,rerun,test,test-result,version-check,bat}
                                                 ...

options:
  -h, --help            show this help message and exit
  --log-base LOG_BASE   The base path for all log directories (default: ./log, to disable: nul)
  --log-level LOG_LEVEL
                        Set log level for the console output, either by numeric or string value (default: warning)

colcon verbs:
  alias                 Create and modify command aliases
  build                 Build a set of packages
  extension-points      List extension points
  extensions            List extensions
  graph                 Generate a visual representation of the dependency graph
  info                  Package information
  list                  List packages, optionally in topological ordering
  metadata              Manage metadata of packages
  mixin                 Manage CLI mixins
  rerun                 Quickly re-run a recently executed verb
  test                  Test a set of packages
  test-result           Show the test results generated when testing a set of
                        packages
  version-check         Compare local package versions with PyPI

  {alias,build,extension-points,extensions,graph,info,list,metadata,mixin,rerun,test,test-result,version-check,bat}
                        call `colcon VERB -h` for specific help

C:\Program Files\Python312\Scripts\colcon aliases:
  bat                   rerun build
                        rerun test

Environment variables:
  CMAKE_COMMAND         The full path to the CMake executable
  COLCON_ALL_SHELLS     Flag to enable all shell extensions
  COLCON_DEFAULTS_FILE  Set path to the yaml file containing the default values
                        for the command line arguments (default:
                        $COLCON_HOME/defaults.yaml)
  COLCON_DEFAULT_EXECUTOR
                        Select the default executor extension
  COLCON_EXTENSION_BLOCKLIST
                        Block extensions which should not be used
  COLCON_HOME           Set the configuration directory (default: ~/.colcon)
  COLCON_LOG_LEVEL      Set the log level (debug|10, info|20, warn|30,
                        error|40, critical|50, or any other positive numeric
                        value)
  COLCON_MIXIN_PATH     Provide additional directories to look for mixin files.
                        Separate individual directories with colons.
  COLCON_WARNINGS       Set the warnings filter similar to PYTHONWARNINGS
                        except that the module entry is implicitly set to
                        'colcon.*'
  CTEST_COMMAND         The full path to the CTest executable
  POWERSHELL_COMMAND    The full path to the PowerShell executable

For more help and usage tips, see https://colcon.readthedocs.io

Showing the "full" program name where appropriate in some parts of the
help output is useful, but in this context, we're really referring more
to the program's title in a more abstract sense. Since we don't want to
re-invoke colcon_core.command.get_prog_name, we can narrow our current
use of the argparse reported prog to only the basename which will
usually give us exactly what we want.
@cottsay cottsay added the bug Something isn't working label Jun 6, 2024
@cottsay cottsay self-assigned this Jun 6, 2024
@cottsay cottsay added this to the 0.1.1 milestone Jun 6, 2024
@codecov-commenter
Copy link

codecov-commenter commented Jun 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.59%. Comparing base (aa1e317) to head (57442d3).

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #14      +/-   ##
==========================================
+ Coverage   86.44%   86.59%   +0.15%     
==========================================
  Files           6        6              
  Lines         177      179       +2     
  Branches       30       30              
==========================================
+ Hits          153      155       +2     
  Misses         22       22              
  Partials        2        2              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@cottsay cottsay merged commit 38c71a1 into main Jun 13, 2024
17 checks passed
@cottsay cottsay deleted the cottsay/consistent-prog-name branch June 13, 2024 19:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

Successfully merging this pull request may close these issues.

3 participants