Is there a way to implement multiple level verbs?
See original GitHub issueIssue by akfish Thursday Oct 31, 2013 at 19:48 GMT _Originally opened as https://github.com/gsscoder/commandline/issues/107_
I am trying to make an app with multiple level of verbs, something like:
app repo list
app repo add
app account list
What I tried is:
class Options
{
#region Global Options
//...
#endregion
#region Help
//..
#endregion
#region Verbs
[VerbOption("account", HelpText = "Manage mail accounts")]
public AccountOptions AccountVerb { get; set; }
[VerbOption("repo", HelpText = "Manage repositories")]
public RepoOptions RepoVerb { get; set; }
#endregion
}
In each verb, nested a sub verb:
class AccountOptions : IOptions
{
[VerbOption("add", HelpText = "Add an account")]
public AddOption AddVerb { get; set; }
//And so on....
public class AddOption : IOptions
{
}
//And so on....
}
main:
class Program
{
static void Main(string[] args)
{
string theVerb = null;
IOptions theOptions = null;
var options = new Options();
if (CommandLine.Parser.Default.ParseArguments(args, options, (verb, subOptions) =>
{
theVerb = verb;
if (verb != null)
theOptions = subOptions as IOptions;
}))
{
theOptions.Execute(options);
}
else
{
Console.Error.WriteLine("Command line parsing error.");
}
}
}
I was able to get first level of verbs to working (e.g. app repo
, app account
, as the documents said. But the second level ones (app account list
, app account add
) didn’t.
So is there a way to do this? Thanks.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:4
- Comments:13 (12 by maintainers)
Top Results From Across the Web
Is there a way to implement multiple level verbs? #107
I am trying to make an app with multiple level of verbs, something like: app repo list app repo add app account list...
Read more >How To Use Multiple Verbs | CSU
Multiple verbs (also known as display commands) can be used to summarize several levels of data, or to display summary data and detail...
Read more >The Added Power of Multi-Verb Requests
The basic mechanism is to create a multi-verb request and ensure that the verb at the lowest sort level provides the detail that...
Read more >How to Align Bloom's Verbs with Learning Levels
Learn how to use Bloom's verbs to design learning objectives, activities, and assessments that match the cognitive complexity and challenge of your domain....
Read more >How to use multiple verbs in one sentence properly - YouTube
This spoken English learning video will teach you the rules you need to follow while using two verbs in same simple sentence and...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
A small trick I found that works quite well. When I find a match with an existing sub-parser (verb), I skip the 1st argument, and forward it to another Parser. This could be done recursively, and probably in a better way than reflection.
Comment by akfish Tuesday Dec 02, 2014 at 07:01 GMT
@Nate-Wilkins I was able to implement this feature in my project without actually modifying this project. Here is my implementation: https://github.com/akfish/git-mail/tree/develop/git-mail
You should know that the project linked above was never finished, since later I moved on to node.js for cross-platform purpose and I haven’t been working on .Net platform for almost a year. But the CLI part was completed and would hopefully give you some hints.