dswisher / yaclops

Yet another command-line options parser
MIT License
2 stars 1 forks source link

Add support for parameter groups #2

Open cj525 opened 9 years ago

cj525 commented 9 years ago

Ex: ProcessRecords ( --type="cat" | --all )

Would process records of particular type, i.e. cat, or, all of the records. I would like the option of requiring explicit selection "all" records for this example.

dswisher commented 7 years ago

This example seems to imply that type is a set, making foo --type="cat" --type="dog" a valid command. If so, then --all would need to populate all possible values of the set, further implying that type is a set based on an enumeration.

Is there another usage that I'm overlooking?

Note: other possible syntax variations would be foo --type=["cat", "dog"] or foo --type="cat,dog". I'm not a fan of these, but wanted them written down.

cj525 commented 7 years ago

I suppose my original example wasn't very good because it implied that "cat" was a dynamic value in which case --all doesn't make much sense. I like the syntax options though. Perhaps unquoted for single word terms: foo --type=[cat, dog,"even bigger cat"].

With this feature I might presume that I could:

public enum AnimalTypes 
{
    [Summary("meow")]
    Cat,
    [Summary("woof")]
    Dog,
    [Summary("roar")]
    [LongName("even bigger cat")]
    EvenBiggerCat,
}

[NamedParameter("type")]
public AnimalTypes AnimalType { get; set; }

Here's what I was thinking:

Valueless Parameter Groups This would lead to a [GroupSetter] mechanism being needed so that you can specify all of the known options for a particular group.

An application that feeds your pets but only explicitly known pet types:

FeedPets --cat --dog --bird
FeedPets --all

Group-Setter An application that batch transcodes videos, optionally copying metadata from the header. This has two groups: the type of encoding to process and which metadata to copy:

Transcode --folder=D:\Videos --out=dirac --x264 --divx --vp9 --copyGPS --copyDRM
Transcode --folder=D:\Videos --out=dirac --allCodecs --allMeta

It probably makes sense to not assume that the feature is "all of group". Going back to my pet feeding example... consider a set with the following supported members: birds, cats, dogs, fish, and turtles There may be arbitrary and potentially overlapping groups:

FeedPets --four-legged --swimmers

Admittedly it is not immediately clear whether we are feeding everything except the birds or if we are feeding just the turtles. Perhaps an and/or grouping mechanism is different feature.

cj525 commented 7 years ago

Presumably there'd be a --turtles so the former would mean everything except the birds. Silly me. However, it might be interesting to provide negating syntax:

FeedPets --!birds