Add shared CLI helper and argparse to scripts with raw sys.argv#922
Open
dvida wants to merge 1 commit into
Open
Add shared CLI helper and argparse to scripts with raw sys.argv#922dvida wants to merge 1 commit into
dvida wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
RMS/CLITools.pywithaddConfigArgument()andloadConfig()— a standard way to register-c/--config(plain string, no legacynargs=1+[0]indexing) and load the config vialoadConfigFromDirectory, accepting the value asNone, string, or 1-element list.sys.argvby hand to argparse, so all tools now support-h/--help:Utils/PointsViewer.py— also fixes aNameErrorcrash (plt.title(name)withnameundefined) and removes the hardcoded.configpathUtils/Grouping3DRunner.py— also removes hardcoded.configUtils/setAllCameraParams.pyUtils/SetCameraAddress.py— previous manual usage text preserved as the--helpepilogUtils/SaturationSimulation.py— previously had no CLI at all; the hardcoded demo parameters are now flags with the old values as defaultsExisting scripts using
nargs=1are unchanged and can migrate to the helper opportunistically.Testing
python -m Utils.<X> -hprints proper usage for all five scriptsloadConfig()tested with string path, 1-element list,'.'(config from data dir), andNone(default config)🤖 Generated with Claude Code