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

feature: allow to save userdefaults in a seperate file #1748

Closed
mknj opened this issue Jun 6, 2022 · 3 comments
Closed

feature: allow to save userdefaults in a seperate file #1748

mknj opened this issue Jun 6, 2022 · 3 comments

Comments

@mknj
Copy link

mknj commented Jun 6, 2022

Env variables work nicely for programs with a small number of arguments.

With more arguments it would be nice to be able to save the given arguments as defaults. (i.e. as json file under $HOME/.config/programname.json)

example

# save defaults without actually calling the program
$ program --saveAsDefaults --host google.com --port 42 --username bob --color blue
$ cat ~/.config/program.json
{
  "host":"google.com",
  "port":42,
  "username":"bob",
  "color":"blue"
}
@shadowspawn
Copy link
Collaborator

Thanks for the description.

Configuration files is a big topic, with lots of variation in where they are stored, and the configuration file format, let alone writing. Configuration files were discussed in #1584, and there was so little common ground in that discussion that we ended up just improving support for authors doing it themselves. (e.g as being used in #1713)

You are describing something (deliberately) more self-contained and limited. I'm not sure what percentage of users that will suit. Happy to leave this open for a while and see what feedback and likes it gets.

@mknj
Copy link
Author

mknj commented Jun 6, 2022

My intention was a bit different, but after reading the comments i understand that this is a broader issue.

you could align my need with the '-c --config ' proposal by making ~/.config/program.json the default config file.

Feel free to close the issue.

@jpilgrim
Copy link

jpilgrim commented May 6, 2024

I have written an extension to commander.js which does exactly this: cmdsettings

So, this issue is just to inform people if they need this feature -- there it is.

It may not cover all cases, but it serves me well in several projects.

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

No branches or pull requests

3 participants