Skip to content
This repository has been archived by the owner. It is now read-only.

Support -c and --config with Config File #3

Closed
kliu57 opened this issue Oct 5, 2023 · 1 comment · Fixed by #4
Closed

Support -c and --config with Config File #3

kliu57 opened this issue Oct 5, 2023 · 1 comment · Fixed by #4

Comments

@kliu57
Copy link
Contributor

kliu57 commented Oct 5, 2023

I would like to implement the following feature:

Allow users to specify all of their options in a TOML formatted configuration file instead of having to pass them all as command line arguments every time. For example, consider the following config file, ./config.toml:

output = "./build"
stylesheet = "https://cdn.jsdelivr.net/npm/water.css@2/out/water.css"

A user could run the cli by doing either of the following:

# Option 1: use command line arguments:
python til_converter.py examples/sample.txt --output "./build" --stylesheet "https://cdn.jsdelivr.net/npm/water.css@2/out/water.css"

# Option 2: use a config file
python til_converter.py examples/sample.txt -c examples/config.toml

Requirements

  1. The -c or --config flags accept a file path to a TOML-based config file.
  2. If the file is missing, or can't be parsed as TOML, exit with an appropriate error message.
  3. If the -c or --config option is provided, ignore all other options (i.e., a config file overrides other options on the command line).
  4. The program should ignore any options in the config file it doesn't recognize. For example, if the app doesn't support stylesheets, ignore a stylesheet property.
  5. If the config file is missing any options, assume the usual defaults.
@kliu57
Copy link
Contributor Author

kliu57 commented Oct 6, 2023

@alikhan1998 Hi Ali, I have completing implementing this issue. Please check out the pull request linked to this issue, thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant