Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Take inputs from environment variables #10

Open
treykeown opened this issue Jun 8, 2023 · 1 comment
Open

Take inputs from environment variables #10

treykeown opened this issue Jun 8, 2023 · 1 comment
Labels
design needed Code architectural or aesthetic-related enhancement New feature or request
Milestone

Comments

@treykeown
Copy link
Owner

treykeown commented Jun 8, 2023

This isn't an uncommon pattern - could be useful to allow some parameters to take their input from an environment variable. There are some unresolved questions around naming, though:

  1. What should all variables be prefixed with? The program name has remained a fairly flexible concept - it can be a script name script.py, a module name test.script, or manually set by the user. This is not the best thing for creating concise and scoped variable names. Maybe only enable environment variables if the user provides a prefix to arguably.run()?
  2. What if there is an existing environment variable the user wants to connect to a parameter? Is there a concise way of doing this?
  3. Would this only be useful for options, or could positional parameters also work?
@treykeown treykeown added the enhancement New feature or request label Jun 8, 2023
@treykeown treykeown added the design needed Code architectural or aesthetic-related label Jun 18, 2023
@treykeown treykeown added this to the v2.0.0 milestone Jun 19, 2023
@treykeown
Copy link
Owner Author

treykeown commented Jun 20, 2023

Current plan for implementing this: In arguably.run(), take in a dict[str, list[str]] that maps a short environment variable name (like SERVER_IP) to a list of fully-qualified names ["MYSERVERAPP_RUN_SERVER_IP", "MYSERVERAPP_CHECK_SERVER_IP"]. The alternatives:

  1. Don't have this feature at all
  2. Make this Annotated[]
  3. Fit this in the docstring, somehow.

Of these alternatives, option 3 is most attractive - while a little clunky, it requires documenting this behavior in the docstring, which is a good thing.

@treykeown treykeown modified the milestones: v2.0.0, Goals Jun 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
design needed Code architectural or aesthetic-related enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant