Skip to content

verbs with same or options #935

Open
@rychlym

Description

@rychlym

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions