{"action":"created","issue":{"url":"https://api.github.com/repos/natemcmaster/CommandLineUtils/issues/149","repository_url":"https://api.github.com/repos/natemcmaster/CommandLineUtils","labels_url":"https://api.github.com/repos/natemcmaster/CommandLineUtils/issues/149/labels{/name}","comments_url":"https://api.github.com/repos/natemcmaster/CommandLineUtils/issues/149/comments","events_url":"https://api.github.com/repos/natemcmaster/CommandLineUtils/issues/149/events","html_url":"https://github.com/natemcmaster/CommandLineUtils/issues/149","id":358414317,"node_id":"MDU6SXNzdWUzNTg0MTQzMTc=","number":149,"title":"Is CommandLineApplication.Parse supposed to trigger validation?","user":{"login":"thomaslevesque","id":1864281,"node_id":"MDQ6VXNlcjE4NjQyODE=","avatar_url":"https://avatars3.githubusercontent.com/u/1864281?v=4","gravatar_id":"","url":"https://api.github.com/users/thomaslevesque","html_url":"https://github.com/thomaslevesque","followers_url":"https://api.github.com/users/thomaslevesque/followers","following_url":"https://api.github.com/users/thomaslevesque/following{/other_user}","gists_url":"https://api.github.com/users/thomaslevesque/gists{/gist_id}","starred_url":"https://api.github.com/users/thomaslevesque/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thomaslevesque/subscriptions","organizations_url":"https://api.github.com/users/thomaslevesque/orgs","repos_url":"https://api.github.com/users/thomaslevesque/repos","events_url":"https://api.github.com/users/thomaslevesque/events{/privacy}","received_events_url":"https://api.github.com/users/thomaslevesque/received_events","type":"User","site_admin":false},"labels":[{"id":669403797,"node_id":"MDU6TGFiZWw2Njk0MDM3OTc=","url":"https://api.github.com/repos/natemcmaster/CommandLineUtils/labels/question","name":"question","color":"cc317c","default":true}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-09-09T21:31:28Z","updated_at":"2018-09-25T16:11:28Z","closed_at":"2018-09-25T16:11:28Z","author_association":"NONE","body":"I'm using CommandLineUtils to parse command line options, but I don't want to use the library's execution engine, because I don't want to refactor the existing code to fit that model. So I'm using the `Parse` method like this:\r\n\r\n            var app = new CommandLineApplication(throwOnUnexpectedArg: false);\r\n            var configurationOption = app.Option<string>(\r\n                \"-c|--configuration\",\r\n                \"The build configuration\",\r\n                CommandOptionType.SingleValue,\r\n                option => option.Accepts(builder => builder.Values(\"Debug\", \"Release\")));\r\n            app.Parse(args);\r\n            var configuration = configurationOption.HasValue() ? configurationOption.Value() : \"Release\";\r\n\r\nHowever, `option.Accepts(builder => builder.Values(\"Debug\", \"Release\"))` seems to have no effect. It looks like validation isn't run. Is this the expected behavior? If not, how could I achieve what I'm trying to do?\r\n\r\nI know I could just check the value manually, but I was hoping to take advantage of CommandLineUtils' validation mechanism."},"comment":{"url":"https://api.github.com/repos/natemcmaster/CommandLineUtils/issues/comments/424406648","html_url":"https://github.com/natemcmaster/CommandLineUtils/issues/149#issuecomment-424406648","issue_url":"https://api.github.com/repos/natemcmaster/CommandLineUtils/issues/149","id":424406648,"node_id":"MDEyOklzc3VlQ29tbWVudDQyNDQwNjY0OA==","user":{"login":"natemcmaster","id":2696087,"node_id":"MDQ6VXNlcjI2OTYwODc=","avatar_url":"https://avatars0.githubusercontent.com/u/2696087?v=4","gravatar_id":"","url":"https://api.github.com/users/natemcmaster","html_url":"https://github.com/natemcmaster","followers_url":"https://api.github.com/users/natemcmaster/followers","following_url":"https://api.github.com/users/natemcmaster/following{/other_user}","gists_url":"https://api.github.com/users/natemcmaster/gists{/gist_id}","starred_url":"https://api.github.com/users/natemcmaster/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/natemcmaster/subscriptions","organizations_url":"https://api.github.com/users/natemcmaster/orgs","repos_url":"https://api.github.com/users/natemcmaster/repos","events_url":"https://api.github.com/users/natemcmaster/events{/privacy}","received_events_url":"https://api.github.com/users/natemcmaster/received_events","type":"User","site_admin":false},"created_at":"2018-09-25T16:11:28Z","updated_at":"2018-09-25T16:11:28Z","author_association":"OWNER","body":"Yes, this is the expected behavior. If you want to run validation manually, you can do this:\r\n```c#\r\nvar parseResult = app.Parse(args);\r\nvar validationResult = parseResult.SelectedCommand.GetValidationResult();\r\n```\r\n\r\nFYI checkout what CommandLineApplication.Execute does: https://github.com/natemcmaster/CommandLineUtils/blob/2753a1cb77617cfd0022b0a74d1e98a101322daf/src/CommandLineUtils/CommandLineApplication.cs#L695-L712"}}
{"actor":{"display_login":"natemcmaster"}}