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

Provide CLI arguments in config file #5099

Closed
2 tasks done
SamuelMarks opened this issue Aug 29, 2023 · 1 comment
Closed
2 tasks done

Provide CLI arguments in config file #5099

SamuelMarks opened this issue Aug 29, 2023 · 1 comment
Labels
C-enhancement Category: Raise on the bar on expectations

Comments

@SamuelMarks
Copy link

Please complete the following tasks

Clap Version

4.4.0

Describe your use case

Writing version and daemon managers. So you begin by downloading, installing, and starting a package. Then you stop, install-service (daemon).

Either by including all the arguments with you every step of the way, or using a config file.

Describe the solution you'd like

My use case:

  • Store JSON of version → all provided CLI arguments (uses ENV if not provided otherwise the default value)

To give a concrete of what the JSON would look like:

{
  "15.3.1": {
    "Port": 5430,
    "Database": "my_15_3_db",
    "Username": "thespp",
    "Password": "cxvsd",
  },
  "15.4.0": {
    "Port": 5432,
    "Database": "my_15_4_db",
    "Username": "cvxvx",
    "Password": "45j45lF",
  }
}

Alternatives, if applicable

Working prototype (in Go, but planning a Rust rewrite): https://github.com/offscale/postgres-version-manager-go

I suppose I could use
https://github.com/aobatact/clap-serde

Or straight up serde on the struct in question and use it that way. But there seems to be a lot of intricacies to consider, like how do I know when:

  • A default value has been overriden by an env var or by a CLI arg or given in a config file

Also how do I deserialise it with a version per JSON key. It was pretty hacky to get working in Go.

Additional Context

Related: #3113

That way you can either provide this JSON file in a --config or it will use the default location (assuming you don't have --no-config-write set).

@SamuelMarks SamuelMarks added the C-enhancement Category: Raise on the bar on expectations label Aug 29, 2023
@epage
Copy link
Member

epage commented Aug 29, 2023

Closing in favor of #2763

@epage epage closed this as not planned Won't fix, can't repro, duplicate, stale Aug 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: Raise on the bar on expectations
Projects
None yet
Development

No branches or pull requests

2 participants