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

verbs with same or options #935

Open
rychlym opened this issue Aug 19, 2024 · 0 comments
Open

verbs with same or options #935

rychlym opened this issue Aug 19, 2024 · 0 comments

Comments

@rychlym
Copy link

rychlym commented Aug 19, 2024

Hello, I would like to ask you, whether there can be considered having some verbs with similar or even same options? That is, when the option classes have some relations like inheritance or they are based on same type in F#. Is there possibility to have somehow Parsed with additional info related to verb itself - like verb string or verb attribute?

An example in F#

open CommandLine

type CommonOptions = {
    [<Option('c', "connectionString", Required = true, HelpText = "MongoDB connection string.")>]
    ConnectionString: string
    [<Option('n', "dbCollection", Required = true, HelpText = "Database and collection name in the format 'databaseName.collectionName'.")>]
    DbCollection: string
    [<Option('d', "dir", Required = true, HelpText = "Directory path for serialization or deserialization.")>]
    Directory: string
    [<Option('b', "batchSize", Default = 1000, HelpText = "Batch size for processing.")>]
    BatchSize: int
    [<Option('s', "skip", Default = 0, HelpText = "Number of chunks to skip.")>]
    Skip: int
}
[<Verb("dump", HelpText = "Serialize (dump) a MongoDB collection to a json.gz file.")>]
type SerializeOptions = CommonOptions

[<Verb("restore", HelpText = "Deserialize (restore) a json.gz file to a MongoDB collection.")>]
type DeserializeOptions = CommonOptions

Then the classic handling as described in the main page
let result = Parser.Default.ParseArguments<SerializeOptions, DeserializeOptions>(argv) ...
won't work (matches with NotParsed).

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

1 participant