{"action":"created","issue":{"url":"https://api.github.com/repos/docopt/docopt.go/issues/41","repository_url":"https://api.github.com/repos/docopt/docopt.go","labels_url":"https://api.github.com/repos/docopt/docopt.go/issues/41/labels{/name}","comments_url":"https://api.github.com/repos/docopt/docopt.go/issues/41/comments","events_url":"https://api.github.com/repos/docopt/docopt.go/issues/41/events","html_url":"https://github.com/docopt/docopt.go/pull/41","id":192943160,"number":41,"title":"Refactor and API improvements","user":{"login":"aviddiviner","id":835967,"avatar_url":"https://avatars.githubusercontent.com/u/835967?v=3","gravatar_id":"","url":"https://api.github.com/users/aviddiviner","html_url":"https://github.com/aviddiviner","followers_url":"https://api.github.com/users/aviddiviner/followers","following_url":"https://api.github.com/users/aviddiviner/following{/other_user}","gists_url":"https://api.github.com/users/aviddiviner/gists{/gist_id}","starred_url":"https://api.github.com/users/aviddiviner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aviddiviner/subscriptions","organizations_url":"https://api.github.com/users/aviddiviner/orgs","repos_url":"https://api.github.com/users/aviddiviner/repos","events_url":"https://api.github.com/users/aviddiviner/events{/privacy}","received_events_url":"https://api.github.com/users/aviddiviner/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-12-01T19:44:27Z","updated_at":"2016-12-16T15:53:44Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/docopt/docopt.go/pulls/41","html_url":"https://github.com/docopt/docopt.go/pull/41","diff_url":"https://github.com/docopt/docopt.go/pull/41.diff","patch_url":"https://github.com/docopt/docopt.go/pull/41.patch"},"body":"Hi there. I've been working on my own fork of this project for a while to clean up the API. I've reached a stage where I'm happy for my changes to be merged back in if you're interested in using them. You can see what's basically changed by reading the README: https://github.com/aviddiviner/docopt-go#api\r\n\r\nBut I'll list the salient points here for your summary:\r\n\r\n* Instead of the previous single, all-purpose API exposed by this package, namely: `Parse(doc string, argv []string, help bool, version string, optionsFirst bool, exit ...bool) (map[string]interface{}, error)`, I've added two simpler APIs, such as `ParseDoc(doc string) (Opts, error)`, as well as a custom `Parser` that you can use.\r\n\r\n* I have left the `Parse(...)` function in place (using a new Parser under the hood), so there is no break in backward compatibility.\r\n\r\n* This configurable `Parser` was the reason I did this refactor; previously there was no way for me to unit test my own docopt docs (i.e. test some command line invocations and see that I was getting the correct options back). With the addition of the parser, you can control the usage printing / exit behaviour.\r\n\r\n* The new `Opts` type which is returned has some convenience methods for easy type conversion, so this code:\r\n```go\r\nopts, _ := Parse(\"Usage: foo <option>\", nil, true, \"\", false, true)\r\nif opt, ok := opts[\"<option>\"]; ok {\r\n  if s, ok := opt.(string); ok {\r\n    if val, err := strconv.Atoi(s); err != nil {\r\n      ...\r\n    }\r\n  }\r\n}\r\n```\r\nbecomes this:\r\n```go\r\nopts, _ := ParseDoc(\"Usage: foo <option>\")\r\nval, _ := opts.Int(\"<option>\")\r\n```\r\nwhile still being just a `map[string]interface{}` under the hood.\r\n\r\n* The examples in the `examples/` folder are now tested as part of the build process. Some other small coverage improvements were made.\r\n\r\nAnd some other little fixes here and there. But mostly, it's about having a cleaner API, and being able to control the \"exit and print usage\" behaviour for testing.\r\n\r\nTake a look. I hope you like it, and would want to merge it back in! Let me know 😄 \r\n"},"comment":{"url":"https://api.github.com/repos/docopt/docopt.go/issues/comments/267624904","html_url":"https://github.com/docopt/docopt.go/pull/41#issuecomment-267624904","issue_url":"https://api.github.com/repos/docopt/docopt.go/issues/41","id":267624904,"user":{"login":"aviddiviner","id":835967,"avatar_url":"https://avatars.githubusercontent.com/u/835967?v=3","gravatar_id":"","url":"https://api.github.com/users/aviddiviner","html_url":"https://github.com/aviddiviner","followers_url":"https://api.github.com/users/aviddiviner/followers","following_url":"https://api.github.com/users/aviddiviner/following{/other_user}","gists_url":"https://api.github.com/users/aviddiviner/gists{/gist_id}","starred_url":"https://api.github.com/users/aviddiviner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aviddiviner/subscriptions","organizations_url":"https://api.github.com/users/aviddiviner/orgs","repos_url":"https://api.github.com/users/aviddiviner/repos","events_url":"https://api.github.com/users/aviddiviner/events{/privacy}","received_events_url":"https://api.github.com/users/aviddiviner/received_events","type":"User","site_admin":false},"created_at":"2016-12-16T15:53:43Z","updated_at":"2016-12-16T15:53:43Z","body":"By my count, this PR fixes these issues:\r\nhttps://github.com/docopt/docopt.go/issues/3\r\nhttps://github.com/docopt/docopt.go/issues/4\r\nhttps://github.com/docopt/docopt.go/issues/17\r\nhttps://github.com/docopt/docopt.go/issues/31\r\nhttps://github.com/docopt/docopt.go/issues/39\r\n\r\nAnd provides the features requested by these PRs:\r\nhttps://github.com/docopt/docopt.go/pull/20\r\nhttps://github.com/docopt/docopt.go/pull/30\r\nhttps://github.com/docopt/docopt.go/pull/42"}}
{"actor":{"display_login":"aviddiviner"}}