Skip to content

add command line arguments#53

Open
DanielRosiqueEgea wants to merge 2 commits intoQiuYannnn:mainfrom
DanielRosiqueEgea:add_command_line_arguments
Open

add command line arguments#53
DanielRosiqueEgea wants to merge 2 commits intoQiuYannnn:mainfrom
DanielRosiqueEgea:add_command_line_arguments

Conversation

@DanielRosiqueEgea
Copy link
Copy Markdown

Added support for command line arguments to enable faster and more flexible execution. If no arguments (or only some) are provided, the program will fall back to using the original input() prompts.

Why:
Using command line arguments provides several benefits:

  • Enables easier debugging and testing
  • Supports automation and scripting
  • Avoids blocking interactive prompts that are not friendly for non-interactive environments (e.g., CI/CD, batch scripts)

This change maintains backward compatibility by preserving interactive prompts when needed.

Example of a launch.json:


{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Run with CLI args",
      "type": "debugpy",
      "request": "launch",
      "program": "${workspaceFolder}/main.py",
      "console": "integratedTerminal",
      "args": [
        "-v", "1",
        "-i", "${workspaceFolder}/sample_data",
        "-o", "${workspaceFolder}/organized_output",
        "-c", "1"
      ]
    }
  ]
}

Copy link
Copy Markdown

@brianrmurphy brianrmurphy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to use correct spelling of option "classification" (not "clasification").

main.py Outdated
print("Values: ", values)
for currentArgument, currentValue in arguments:
if currentArgument in ("-h", "--help"):
print("Usage: python main.py [-h] [-v MODE] [-i INPUT] [-o OUTPUT] [-c CLASIFICATION_MODE]")
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spelling: "CLASSIFICATION_MODE".

main.py Outdated
argumentList = sys.argv[1:]

options = "hv:i:o:c:"
long_options = ["help","verbose=", "input=", "output=", "clasification_mode="]
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spelling: replace with "classification_mode=".

main.py Outdated
verbose = None
input_path = None
output_path = None
clasification_mode = None
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here...

@DanielRosiqueEgea
Copy link
Copy Markdown
Author

Better to use correct spelling of option "classification" (not "clasification").

So sorry, English is not my first language, thank you so much for pointing out my error.
It has been corrected now.

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.

2 participants