1. import argparse
  2. import sys
  3. def reload_config(parser):
  4. """Reloads CLI arguments configuration."""
  5. parser.clear_defaults() # Remove existing defaults
  6. parser.add_argument("--config", type=str, help="Path to configuration file")
  7. # Add any other minimal arguments here. Example:
  8. parser.add_argument("--verbose", action="store_true", help="Enable verbose output")
  9. return parser
  10. def main():
  11. """Main function to handle argument parsing and configuration."""
  12. parser = argparse.ArgumentParser(description="Minimal CLI configuration.")
  13. # Reload the configuration
  14. parser = reload_config(parser)
  15. args = parser.parse_args()
  16. # Access arguments
  17. if args.config:
  18. print(f"Configuration loaded from: {args.config}")
  19. else:
  20. print("Using default configuration.")
  21. if args.verbose:
  22. print("Verbose mode enabled.")
  23. # Your application logic here, using the parsed arguments
  24. print("Running application...")
  25. if __name__ == "__main__":
  26. main()

Add your comment