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

Issue with env showing in help #206

Open
scriptanium opened this issue Jan 31, 2023 · 4 comments
Open

Issue with env showing in help #206

scriptanium opened this issue Jan 31, 2023 · 4 comments

Comments

@scriptanium
Copy link

scriptanium commented Jan 31, 2023

Hello,

As you can see on this picture and told in the documentation, my env var are put in the struct tags of the args struct with default values.
image

And here you can see that for any reason env var are also shown as arguments sadly.
image

It did not do this previously but my project evolved (but the library always has been in version 1.4.3 and this part kept untouched) and so I don't understand why there is a problem now and how to fix it.

I don't know if I missed something or if it is finally normal, but if it is not, maybe I should try to work on a PR, but I am pretty overloaded, so sadly (for me) I may not be able to try to fix this in the short term.

@alexflint
Copy link
Owner

Is it that you wanted the environment variable to not show up in the help text?

@scriptanium
Copy link
Author

scriptanium commented Feb 1, 2023

Yes (and not to be considered as arguments with --)
I still find your struct tags configuration even of ENV very practical.
If it not possible I may try to just manually use os.GetEnv.

@alexflint
Copy link
Owner

I'm not completely clear on what you mean by "not to be considered as arguments with --".

Can you show me how you would want the help output to appear, for the example from your original comment above? It would be most helpful if you could copy and paste the output from your original comment and edit it to how you would want it to appear.

@scriptanium
Copy link
Author

scriptanium commented Feb 3, 2023

It is :

Usage: schematic_rest [--port PORT] [--store STORE] [--size_max SIZE_MAX] [--db DB] [--schem_dir SCHEM_DIR] [--log_level LOG_LEVEL]

Options:
  --port PORT [default: 80, env: PORT]
  --store STORE [default: /app/data, env: STORE]
  --size_max SIZE_MAX [default: 32M, env: SIZE_MAX]
  --db DB [default: database.db, env: DB]
  --schem_dir SCHEM_DIR [default: schemata, env: SCHEM_DIR]
  --log_level LOG_LEVEL [default: INFO, env: LOG_LEVEL]
  --help, -h             display this help and exit
  --version              display version and exit

And it needs to be :

v0.0.0
Usage: schematic_rest

Options:
  --help, -h             display this help and exit
  --version              display version and exit

While still reading the env variables in the code.

Like if environment variable are not specified as command line argument with short or long options ("-short or --long") that no command line options are generated for them and nothing present in the help. (except wanted explicitely)

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

No branches or pull requests

2 participants