Skip to content

Add shared CLI helper and argparse to scripts with raw sys.argv#922

Open
dvida wants to merge 1 commit into
prereleasefrom
cli-tools-argparse
Open

Add shared CLI helper and argparse to scripts with raw sys.argv#922
dvida wants to merge 1 commit into
prereleasefrom
cli-tools-argparse

Conversation

@dvida

@dvida dvida commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Summary

  • New RMS/CLITools.py with addConfigArgument() and loadConfig() — a standard way to register -c/--config (plain string, no legacy nargs=1 + [0] indexing) and load the config via loadConfigFromDirectory, accepting the value as None, string, or 1-element list.
  • Converts the five scripts that still parsed sys.argv by hand to argparse, so all tools now support -h/--help:
    • Utils/PointsViewer.py — also fixes a NameError crash (plt.title(name) with name undefined) and removes the hardcoded .config path
    • Utils/Grouping3DRunner.py — also removes hardcoded .config
    • Utils/setAllCameraParams.py
    • Utils/SetCameraAddress.py — previous manual usage text preserved as the --help epilog
    • Utils/SaturationSimulation.py — previously had no CLI at all; the hardcoded demo parameters are now flags with the old values as defaults

Existing scripts using nargs=1 are unchanged and can migrate to the helper opportunistically.

Testing

  • python -m Utils.<X> -h prints proper usage for all five scripts
  • loadConfig() tested with string path, 1-element list, '.' (config from data dir), and None (default config)

🤖 Generated with Claude Code

Add RMS/CLITools.py with addConfigArgument() and loadConfig() helpers
that standardize the -c/--config argument without the legacy nargs=1
pattern, and normalize str/list inputs before calling
loadConfigFromDirectory.

Convert the five scripts that still parsed sys.argv by hand to argparse
so they all support -h/--help: PointsViewer, Grouping3DRunner,
setAllCameraParams, SetCameraAddress, and SaturationSimulation (which
previously had no CLI at all - its hardcoded demo parameters are now
arguments with the old values as defaults).

Also fixes a NameError crash in PointsViewer (plt.title referenced an
undefined variable) and removes its hardcoded .config path.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant