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

Handling of config structs with tagged struct fields #2

Open
hariso opened this issue Dec 2, 2024 · 2 comments
Open

Handling of config structs with tagged struct fields #2

hariso opened this issue Dec 2, 2024 · 2 comments

Comments

@hariso
Copy link

hariso commented Dec 2, 2024

Ecdysis makes it possible to build flags from a struct, and in #1 we added support for parsing nested structs. We found that the following case is possible and needs to be properly handled:

type Config struct {
  DBConfig DBConfig `long:"database config"` 
}
type DBConfig struct {
  URL string `long:"db url"`
}

Nested structs are not flags on their own, they are merely a way to group flags. The goal of this issue is to clarify the usage of tags on nested structs (we can either forbid them, or allow them if we have a way to describe groups of flags).

@lovromazgon
Copy link
Member

IIUC this issue is about adding a prefix to nested flags, correct? For example, these structs:

type Config struct {
  DBConfig DBConfig `long:"database"` 
}
type DBConfig struct {
  URL string `long:"url"`
}

... would result in the flag -database.url=foo, right?

@hariso
Copy link
Author

hariso commented Jan 13, 2025

@lovromazgon Yes, that's one of the options. Another is to just disallow that usage at all. My intention with this issue is to clarify which do we want to use and be consistent with that.

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

No branches or pull requests

2 participants