Hi,
Can I have my program support usage like this:
$git add a.txt
where a.txt is passed to a handler without having a name like git add --file a.txt
If so, is there any documentation/sample for this kind of usage?
Thanks,
You can do this with a command argument:
var addCommand = new Command("add")
{
new Argument<FileInfo>("file") // <-- ARGUMENT NAME...
};
addCommand.Handler = CommandHandler.Create(
(FileInfo file)) => // <-- ...MATCHES HANDLER PARAMETER NAME
{
});
The name isn't passed on the command line, so you can invoke it just like in your example. But the name is used when binding to your command handler, so they should match.
this worked. thanks @jonsequitur !
Thanks @jonsequitur, I was in the process of opening a new issue when this suggestion appeared in the github editor... This example should be included in the docs.
Most helpful comment
Thanks @jonsequitur, I was in the process of opening a new issue when this suggestion appeared in the github editor... This example should be included in the docs.