{"action":"created","issue":{"url":"https://api.github.com/repos/fclp/fluent-command-line-parser/issues/26","labels_url":"https://api.github.com/repos/fclp/fluent-command-line-parser/issues/26/labels{/name}","comments_url":"https://api.github.com/repos/fclp/fluent-command-line-parser/issues/26/comments","events_url":"https://api.github.com/repos/fclp/fluent-command-line-parser/issues/26/events","html_url":"https://github.com/fclp/fluent-command-line-parser/issues/26","id":52959443,"number":26,"title":"Command with parameter","user":{"login":"XVincentX","id":1416224,"avatar_url":"https://avatars.githubusercontent.com/u/1416224?v=3","gravatar_id":"","url":"https://api.github.com/users/XVincentX","html_url":"https://github.com/XVincentX","followers_url":"https://api.github.com/users/XVincentX/followers","following_url":"https://api.github.com/users/XVincentX/following{/other_user}","gists_url":"https://api.github.com/users/XVincentX/gists{/gist_id}","starred_url":"https://api.github.com/users/XVincentX/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/XVincentX/subscriptions","organizations_url":"https://api.github.com/users/XVincentX/orgs","repos_url":"https://api.github.com/users/XVincentX/repos","events_url":"https://api.github.com/users/XVincentX/events{/privacy}","received_events_url":"https://api.github.com/users/XVincentX/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2014-12-27T15:28:08Z","updated_at":"2015-02-27T10:08:19Z","closed_at":null,"body":"Hello,\r\nI was wondering if fclp has got a _command_ concept with per-command parameters.\r\nSomething like this:\r\n\r\n```csharp\r\nSetupCommand(\"create\")\r\n.WithParam(\"initialUrl\")\r\n.Required()\r\n\r\nSetupCommand(\"restore\")\r\n.WithParam(\"fromFile\")\r\n.Required()\r\n```\r\n\r\nAnd then use it in this way\r\n```bash\r\nmyApp.exe create --initialUrl http://www.google.it\r\nmyApp.exe restore --fromFile C:\\data.json\r\n```"},"comment":{"url":"https://api.github.com/repos/fclp/fluent-command-line-parser/issues/comments/76368737","html_url":"https://github.com/fclp/fluent-command-line-parser/issues/26#issuecomment-76368737","issue_url":"https://api.github.com/repos/fclp/fluent-command-line-parser/issues/26","id":76368737,"user":{"login":"siywilliams","id":3663513,"avatar_url":"https://avatars.githubusercontent.com/u/3663513?v=3","gravatar_id":"","url":"https://api.github.com/users/siywilliams","html_url":"https://github.com/siywilliams","followers_url":"https://api.github.com/users/siywilliams/followers","following_url":"https://api.github.com/users/siywilliams/following{/other_user}","gists_url":"https://api.github.com/users/siywilliams/gists{/gist_id}","starred_url":"https://api.github.com/users/siywilliams/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/siywilliams/subscriptions","organizations_url":"https://api.github.com/users/siywilliams/orgs","repos_url":"https://api.github.com/users/siywilliams/repos","events_url":"https://api.github.com/users/siywilliams/events{/privacy}","received_events_url":"https://api.github.com/users/siywilliams/received_events","type":"User","site_admin":false},"created_at":"2015-02-27T10:08:18Z","updated_at":"2015-02-27T10:08:18Z","body":"I'm just exploring how git style commands could work within the existing FCLP framework, if anyone has any feedback that would be great. I'm trying to extend its functionality rather than replace the two current techniques of setting up expected option.\r\n\r\nI'm working on a simple example of an app that tracks files, which can be added and removed.\r\n\r\n```\r\nmyapp add -f \"c:\\file1.txt\" \"c:\\file2.txt\" --verbose --ignore-errors\r\nmyapp remove -f \"c:\\file1.txt\" \"c:\\file2.txt\" --verbose\r\n```\r\n\r\nWe have two commands here, Add and Remove, both can have different options and rules.\r\n\r\n```c#\r\n// Contains all arguments for the add command\r\nclass AddArgs {\r\n bool Verbose;\r\n bool IgnoreErrors;\r\n IEnumerable<string> Files;\r\n}\r\n\r\n// Contains all arguments for the remove command\r\nclass RemoveArgs {\r\n bool Verbose;\r\n IEnumerable<string> Files;\r\n}\r\n```\r\n```c#\r\n// entry point into console app\r\nstatic void Main(string[] args) {\r\n var fclp = new FluentCommandLineParser();\r\n\r\n// use new SetupCommand method to initialise a command\r\n var addCmd = fclp.SetupCommand<AddArgs>(\"add\")\r\n                  .Callback(args => AddArgs(args)); // executed when the add command is used\r\n\r\n// the standard fclp framework, except against the created command rather than the fclp itself\r\n addCmd.Setup(args => args.Verbose)\r\n       .As('v', \"verbose\")\r\n       .SetDefault(false)\r\n       .Description(\"Be verbose\");\r\n       \r\n addCmd.Setup(args => args.IgnoreErrors)\r\n       .As(\"ignore-errors\")\r\n       .SetDefault(false)\r\n       .Description(\"If some files could not be added, do not abort\");\r\n       \r\n addCmd.Setup(args => args.Files)\r\n       .As('f', \"files\")\r\n       .Description(\"Files to be tracked\");\r\n \r\n// add the remove command\r\n var removeCmd = fclp.SetupCommand<RemoveArgs>(\"remove\")\r\n                     .Callback(args => RemoveArgs(args)) // executed when the remove command is used\r\n                     .OnError();\r\n\r\n removeCmd.Setup(args => args.Verbose)\r\n          .As('v', \"verbose\")\r\n          .SetDefault(false)\r\n          .Description(\"Be verbose\");\r\n\r\n removeCmd.Setup(args => args.Files)\r\n          .As('f', \"files\")\r\n          .Description(\"Files to be untracked\");\r\n \r\n fclp.Parse(args);\r\n}\r\n\r\nvoid Add(AddArgs args){\r\n  // add was executed\r\n}\r\n\r\nvoid Remove(RemoveArgs args){\r\n  // remove was executed\r\n}\r\n```\r\n\r\nPerhaps I should have created a gist!\r\n"}}