{"action":"created","issue":{"url":"https://api.github.com/repos/codegangsta/cli/issues/324","labels_url":"https://api.github.com/repos/codegangsta/cli/issues/324/labels{/name}","comments_url":"https://api.github.com/repos/codegangsta/cli/issues/324/comments","events_url":"https://api.github.com/repos/codegangsta/cli/issues/324/events","html_url":"https://github.com/codegangsta/cli/issues/324","id":128980295,"number":324,"title":"Mishandling of a single dash \"-\" as argument causes re-ordering of non-flag arguments","user":{"login":"andreas-kupries","id":577247,"avatar_url":"https://avatars.githubusercontent.com/u/577247?v=3","gravatar_id":"","url":"https://api.github.com/users/andreas-kupries","html_url":"https://github.com/andreas-kupries","followers_url":"https://api.github.com/users/andreas-kupries/followers","following_url":"https://api.github.com/users/andreas-kupries/following{/other_user}","gists_url":"https://api.github.com/users/andreas-kupries/gists{/gist_id}","starred_url":"https://api.github.com/users/andreas-kupries/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andreas-kupries/subscriptions","organizations_url":"https://api.github.com/users/andreas-kupries/orgs","repos_url":"https://api.github.com/users/andreas-kupries/repos","events_url":"https://api.github.com/users/andreas-kupries/events{/privacy}","received_events_url":"https://api.github.com/users/andreas-kupries/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-01-26T23:53:52Z","updated_at":"2016-01-30T03:19:04Z","closed_at":null,"body":"Many a cli which takes a path-argument somewhere will also accept the single dash (\"-\") as argument, with the meaning of \"use stdin\".\r\n\r\nIf the argument accepting the dash is not the first argument, and the command is not given any other options before then the package will mis-identify the dash as a flag-option and re-order the command line for parsing by go flags. go flags then considers the dash as a non-flag argument and leaves it in-place. In the end the command router sees a re-ordered command line.\r\n\r\nExamples\r\n\r\n|command line|slice seen by router|notes|\r\n|----|----|----|\r\n|foo read -something key -|[key -]|Use of -something pre-empted the issue|\r\n|foo read key -|[- key]|The dash is re-ordered to come before the key|\r\n\r\nThe issue is at [https://github.com/codegangsta/cli/blob/f3c8e07836a9d73d1183d8990c2017a589cd1eb3/command.go#L84], where the loop for finding both terminator and first flag checks only that arguments begin with a dash. As the dash-character alone is not a proper flag it should not be considered as a possible fist flag argument.\r\n\r\nThe PR [https://github.com/codegangsta/cli/pull/323] contains a new test demonstrating the issue, and a possible fix for it.\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/codegangsta/cli/issues/comments/177056029","html_url":"https://github.com/codegangsta/cli/issues/324#issuecomment-177056029","issue_url":"https://api.github.com/repos/codegangsta/cli/issues/324","id":177056029,"user":{"login":"jszwedko","id":316880,"avatar_url":"https://avatars.githubusercontent.com/u/316880?v=3","gravatar_id":"","url":"https://api.github.com/users/jszwedko","html_url":"https://github.com/jszwedko","followers_url":"https://api.github.com/users/jszwedko/followers","following_url":"https://api.github.com/users/jszwedko/following{/other_user}","gists_url":"https://api.github.com/users/jszwedko/gists{/gist_id}","starred_url":"https://api.github.com/users/jszwedko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jszwedko/subscriptions","organizations_url":"https://api.github.com/users/jszwedko/orgs","repos_url":"https://api.github.com/users/jszwedko/repos","events_url":"https://api.github.com/users/jszwedko/events{/privacy}","received_events_url":"https://api.github.com/users/jszwedko/received_events","type":"User","site_admin":false},"created_at":"2016-01-30T03:19:04Z","updated_at":"2016-01-30T03:19:04Z","body":"Very descriptive issue report, thank you!"}}