{"action":"created","comment":{"url":"https://api.github.com/repos/schachmat/wego/pulls/comments/40053086","id":40053086,"diff_hunk":"@@ -562,33 +568,24 @@ func marshalLang(rv map[string]interface{}, r *resp) error {\n }\n \n func main() {\n-\tvar numdays = 3\n-\n \tif len(config.APIKey) == 0 {\n \t\tlog.Fatal(\"No API key specified. Setup instructions are in the README.\")\n \t}\n \tparams = append(params, \"key=\"+config.APIKey)\n \n-\tfor _, arg := range os.Args[1:] {\n-\t\tif v, err := strconv.Atoi(arg); err == nil && len(arg) == 1 {\n-\t\t\tnumdays = v\n-\t\t} else {\n-\t\t\tconfig.City = arg\n-\t\t}\n-\t}","path":"we.go","position":63,"original_position":63,"commit_id":"f2381686385019d15501420399b6f84f2ccb04f5","original_commit_id":"f2381686385019d15501420399b6f84f2ccb04f5","user":{"login":"dharmit","id":713521,"avatar_url":"https://avatars.githubusercontent.com/u/713521?v=3","gravatar_id":"","url":"https://api.github.com/users/dharmit","html_url":"https://github.com/dharmit","followers_url":"https://api.github.com/users/dharmit/followers","following_url":"https://api.github.com/users/dharmit/following{/other_user}","gists_url":"https://api.github.com/users/dharmit/gists{/gist_id}","starred_url":"https://api.github.com/users/dharmit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dharmit/subscriptions","organizations_url":"https://api.github.com/users/dharmit/orgs","repos_url":"https://api.github.com/users/dharmit/repos","events_url":"https://api.github.com/users/dharmit/events{/privacy}","received_events_url":"https://api.github.com/users/dharmit/received_events","type":"User","site_admin":false},"body":"Hi @schachmat, below is the code:\r\n~~~\r\n    flag.Parse()\r\n    config.City = city\r\n\r\n    for _, arg := range flag.Args() {\r\n                if v, err := strconv.Atoi(arg); err == nil && len(arg) == 1 { \r\n                        days = v \r\n                } else {\r\n                        config.City = arg \r\n                }\r\n        }\r\n~~~\r\n\r\nWhen I run it as `wego -days 1 -city Mumbai 2 Paris`, it returns 2 days' data for Paris and not 1 day data for Mumbai. So `flag.Args()`, which returns non-flag arguments, is replacing the values set earlier. I don't see a straightforward way of doing this other than using `if...else`. But before I go that way, I want to be sure that I'm thinking correct.","created_at":"2015-09-22T04:55:47Z","updated_at":"2015-09-22T04:55:47Z","html_url":"https://github.com/schachmat/wego/pull/56#discussion_r40053086","pull_request_url":"https://api.github.com/repos/schachmat/wego/pulls/56","_links":{"self":{"href":"https://api.github.com/repos/schachmat/wego/pulls/comments/40053086"},"html":{"href":"https://github.com/schachmat/wego/pull/56#discussion_r40053086"},"pull_request":{"href":"https://api.github.com/repos/schachmat/wego/pulls/56"}}},"pull_request":{"url":"https://api.github.com/repos/schachmat/wego/pulls/56","id":45128535,"html_url":"https://github.com/schachmat/wego/pull/56","diff_url":"https://github.com/schachmat/wego/pull/56.diff","patch_url":"https://github.com/schachmat/wego/pull/56.patch","issue_url":"https://api.github.com/repos/schachmat/wego/issues/56","number":56,"state":"open","locked":false,"title":"Added support for flags","user":{"login":"dharmit","id":713521,"avatar_url":"https://avatars.githubusercontent.com/u/713521?v=3","gravatar_id":"","url":"https://api.github.com/users/dharmit","html_url":"https://github.com/dharmit","followers_url":"https://api.github.com/users/dharmit/followers","following_url":"https://api.github.com/users/dharmit/following{/other_user}","gists_url":"https://api.github.com/users/dharmit/gists{/gist_id}","starred_url":"https://api.github.com/users/dharmit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dharmit/subscriptions","organizations_url":"https://api.github.com/users/dharmit/orgs","repos_url":"https://api.github.com/users/dharmit/repos","events_url":"https://api.github.com/users/dharmit/events{/privacy}","received_events_url":"https://api.github.com/users/dharmit/received_events","type":"User","site_admin":false},"body":"So far, you use `wego 1 Paris` to fetch weather data for Paris for 1\r\nday. With this commit, you use `wego -days 1 -city Paris` to fetch the\r\nsame information. Benefit of this approach is that (1) it prints help\r\nmessage when you do `wego -h` (2) it is clear what data you're seeking.\r\n\r\nPS - I really loved wego. And I am learning golang. So I felt like adding\r\nthis simple support for flags as a part of learning and contributing\r\nback to wego. :smiley: ","created_at":"2015-09-16T03:45:55Z","updated_at":"2015-09-22T04:55:47Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c979fec1d984c14d655b052f016c4144d2a71dbf","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/schachmat/wego/pulls/56/commits","review_comments_url":"https://api.github.com/repos/schachmat/wego/pulls/56/comments","review_comment_url":"https://api.github.com/repos/schachmat/wego/pulls/comments{/number}","comments_url":"https://api.github.com/repos/schachmat/wego/issues/56/comments","statuses_url":"https://api.github.com/repos/schachmat/wego/statuses/f2381686385019d15501420399b6f84f2ccb04f5","head":{"label":"dharmit:flag-support","ref":"flag-support","sha":"f2381686385019d15501420399b6f84f2ccb04f5","user":{"login":"dharmit","id":713521,"avatar_url":"https://avatars.githubusercontent.com/u/713521?v=3","gravatar_id":"","url":"https://api.github.com/users/dharmit","html_url":"https://github.com/dharmit","followers_url":"https://api.github.com/users/dharmit/followers","following_url":"https://api.github.com/users/dharmit/following{/other_user}","gists_url":"https://api.github.com/users/dharmit/gists{/gist_id}","starred_url":"https://api.github.com/users/dharmit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dharmit/subscriptions","organizations_url":"https://api.github.com/users/dharmit/orgs","repos_url":"https://api.github.com/users/dharmit/repos","events_url":"https://api.github.com/users/dharmit/events{/privacy}","received_events_url":"https://api.github.com/users/dharmit/received_events","type":"User","site_admin":false},"repo":{"id":42560874,"name":"wego","full_name":"dharmit/wego","owner":{"login":"dharmit","id":713521,"avatar_url":"https://avatars.githubusercontent.com/u/713521?v=3","gravatar_id":"","url":"https://api.github.com/users/dharmit","html_url":"https://github.com/dharmit","followers_url":"https://api.github.com/users/dharmit/followers","following_url":"https://api.github.com/users/dharmit/following{/other_user}","gists_url":"https://api.github.com/users/dharmit/gists{/gist_id}","starred_url":"https://api.github.com/users/dharmit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dharmit/subscriptions","organizations_url":"https://api.github.com/users/dharmit/orgs","repos_url":"https://api.github.com/users/dharmit/repos","events_url":"https://api.github.com/users/dharmit/events{/privacy}","received_events_url":"https://api.github.com/users/dharmit/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dharmit/wego","description":"weather app for the terminal","fork":true,"url":"https://api.github.com/repos/dharmit/wego","forks_url":"https://api.github.com/repos/dharmit/wego/forks","keys_url":"https://api.github.com/repos/dharmit/wego/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dharmit/wego/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dharmit/wego/teams","hooks_url":"https://api.github.com/repos/dharmit/wego/hooks","issue_events_url":"https://api.github.com/repos/dharmit/wego/issues/events{/number}","events_url":"https://api.github.com/repos/dharmit/wego/events","assignees_url":"https://api.github.com/repos/dharmit/wego/assignees{/user}","branches_url":"https://api.github.com/repos/dharmit/wego/branches{/branch}","tags_url":"https://api.github.com/repos/dharmit/wego/tags","blobs_url":"https://api.github.com/repos/dharmit/wego/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dharmit/wego/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dharmit/wego/git/refs{/sha}","trees_url":"https://api.github.com/repos/dharmit/wego/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dharmit/wego/statuses/{sha}","languages_url":"https://api.github.com/repos/dharmit/wego/languages","stargazers_url":"https://api.github.com/repos/dharmit/wego/stargazers","contributors_url":"https://api.github.com/repos/dharmit/wego/contributors","subscribers_url":"https://api.github.com/repos/dharmit/wego/subscribers","subscription_url":"https://api.github.com/repos/dharmit/wego/subscription","commits_url":"https://api.github.com/repos/dharmit/wego/commits{/sha}","git_commits_url":"https://api.github.com/repos/dharmit/wego/git/commits{/sha}","comments_url":"https://api.github.com/repos/dharmit/wego/comments{/number}","issue_comment_url":"https://api.github.com/repos/dharmit/wego/issues/comments{/number}","contents_url":"https://api.github.com/repos/dharmit/wego/contents/{+path}","compare_url":"https://api.github.com/repos/dharmit/wego/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dharmit/wego/merges","archive_url":"https://api.github.com/repos/dharmit/wego/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dharmit/wego/downloads","issues_url":"https://api.github.com/repos/dharmit/wego/issues{/number}","pulls_url":"https://api.github.com/repos/dharmit/wego/pulls{/number}","milestones_url":"https://api.github.com/repos/dharmit/wego/milestones{/number}","notifications_url":"https://api.github.com/repos/dharmit/wego/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dharmit/wego/labels{/name}","releases_url":"https://api.github.com/repos/dharmit/wego/releases{/id}","created_at":"2015-09-16T02:54:57Z","updated_at":"2015-09-16T02:54:58Z","pushed_at":"2015-09-22T04:11:48Z","git_url":"git://github.com/dharmit/wego.git","ssh_url":"git@github.com:dharmit/wego.git","clone_url":"https://github.com/dharmit/wego.git","svn_url":"https://github.com/dharmit/wego","homepage":"","size":167,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"schachmat:master","ref":"master","sha":"1e4b3417a9a728320fcc63949a33eb03f40e81de","user":{"login":"schachmat","id":2626530,"avatar_url":"https://avatars.githubusercontent.com/u/2626530?v=3","gravatar_id":"","url":"https://api.github.com/users/schachmat","html_url":"https://github.com/schachmat","followers_url":"https://api.github.com/users/schachmat/followers","following_url":"https://api.github.com/users/schachmat/following{/other_user}","gists_url":"https://api.github.com/users/schachmat/gists{/gist_id}","starred_url":"https://api.github.com/users/schachmat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/schachmat/subscriptions","organizations_url":"https://api.github.com/users/schachmat/orgs","repos_url":"https://api.github.com/users/schachmat/repos","events_url":"https://api.github.com/users/schachmat/events{/privacy}","received_events_url":"https://api.github.com/users/schachmat/received_events","type":"User","site_admin":false},"repo":{"id":26971815,"name":"wego","full_name":"schachmat/wego","owner":{"login":"schachmat","id":2626530,"avatar_url":"https://avatars.githubusercontent.com/u/2626530?v=3","gravatar_id":"","url":"https://api.github.com/users/schachmat","html_url":"https://github.com/schachmat","followers_url":"https://api.github.com/users/schachmat/followers","following_url":"https://api.github.com/users/schachmat/following{/other_user}","gists_url":"https://api.github.com/users/schachmat/gists{/gist_id}","starred_url":"https://api.github.com/users/schachmat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/schachmat/subscriptions","organizations_url":"https://api.github.com/users/schachmat/orgs","repos_url":"https://api.github.com/users/schachmat/repos","events_url":"https://api.github.com/users/schachmat/events{/privacy}","received_events_url":"https://api.github.com/users/schachmat/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/schachmat/wego","description":"weather app for the terminal","fork":false,"url":"https://api.github.com/repos/schachmat/wego","forks_url":"https://api.github.com/repos/schachmat/wego/forks","keys_url":"https://api.github.com/repos/schachmat/wego/keys{/key_id}","collaborators_url":"https://api.github.com/repos/schachmat/wego/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/schachmat/wego/teams","hooks_url":"https://api.github.com/repos/schachmat/wego/hooks","issue_events_url":"https://api.github.com/repos/schachmat/wego/issues/events{/number}","events_url":"https://api.github.com/repos/schachmat/wego/events","assignees_url":"https://api.github.com/repos/schachmat/wego/assignees{/user}","branches_url":"https://api.github.com/repos/schachmat/wego/branches{/branch}","tags_url":"https://api.github.com/repos/schachmat/wego/tags","blobs_url":"https://api.github.com/repos/schachmat/wego/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/schachmat/wego/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/schachmat/wego/git/refs{/sha}","trees_url":"https://api.github.com/repos/schachmat/wego/git/trees{/sha}","statuses_url":"https://api.github.com/repos/schachmat/wego/statuses/{sha}","languages_url":"https://api.github.com/repos/schachmat/wego/languages","stargazers_url":"https://api.github.com/repos/schachmat/wego/stargazers","contributors_url":"https://api.github.com/repos/schachmat/wego/contributors","subscribers_url":"https://api.github.com/repos/schachmat/wego/subscribers","subscription_url":"https://api.github.com/repos/schachmat/wego/subscription","commits_url":"https://api.github.com/repos/schachmat/wego/commits{/sha}","git_commits_url":"https://api.github.com/repos/schachmat/wego/git/commits{/sha}","comments_url":"https://api.github.com/repos/schachmat/wego/comments{/number}","issue_comment_url":"https://api.github.com/repos/schachmat/wego/issues/comments{/number}","contents_url":"https://api.github.com/repos/schachmat/wego/contents/{+path}","compare_url":"https://api.github.com/repos/schachmat/wego/compare/{base}...{head}","merges_url":"https://api.github.com/repos/schachmat/wego/merges","archive_url":"https://api.github.com/repos/schachmat/wego/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/schachmat/wego/downloads","issues_url":"https://api.github.com/repos/schachmat/wego/issues{/number}","pulls_url":"https://api.github.com/repos/schachmat/wego/pulls{/number}","milestones_url":"https://api.github.com/repos/schachmat/wego/milestones{/number}","notifications_url":"https://api.github.com/repos/schachmat/wego/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/schachmat/wego/labels{/name}","releases_url":"https://api.github.com/repos/schachmat/wego/releases{/id}","created_at":"2014-11-21T18:09:53Z","updated_at":"2015-09-21T13:27:03Z","pushed_at":"2015-09-16T16:07:42Z","git_url":"git://github.com/schachmat/wego.git","ssh_url":"git@github.com:schachmat/wego.git","clone_url":"https://github.com/schachmat/wego.git","svn_url":"https://github.com/schachmat/wego","homepage":"","size":576,"stargazers_count":2629,"watchers_count":2629,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":160,"mirror_url":null,"open_issues_count":11,"forks":160,"open_issues":11,"watchers":2629,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/schachmat/wego/pulls/56"},"html":{"href":"https://github.com/schachmat/wego/pull/56"},"issue":{"href":"https://api.github.com/repos/schachmat/wego/issues/56"},"comments":{"href":"https://api.github.com/repos/schachmat/wego/issues/56/comments"},"review_comments":{"href":"https://api.github.com/repos/schachmat/wego/pulls/56/comments"},"review_comment":{"href":"https://api.github.com/repos/schachmat/wego/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/schachmat/wego/pulls/56/commits"},"statuses":{"href":"https://api.github.com/repos/schachmat/wego/statuses/f2381686385019d15501420399b6f84f2ccb04f5"}}}}