{"action":"created","comment":{"url":"https://api.github.com/repos/mattermost/platform/pulls/comments/39263658","id":39263658,"diff_hunk":"@@ -6,39 +6,339 @@ package main\n import (\n \t\"flag\"\n \t\"fmt\"\n+\t\"os\"\n+\t\"os/signal\"\n+\t\"strings\"\n+\t\"syscall\"\n+\t\"time\"\n+\n+\tl4g \"code.google.com/p/log4go\"\n \t\"github.com/mattermost/platform/api\"\n \t\"github.com/mattermost/platform/manualtesting\"\n+\t\"github.com/mattermost/platform/model\"\n \t\"github.com/mattermost/platform/utils\"\n \t\"github.com/mattermost/platform/web\"\n-\t\"os\"\n-\t\"os/signal\"\n-\t\"syscall\"\n )\n \n+var flagCmdCreateTeam bool\n+var flagCmdCreateUser bool\n+var flagCmdAssignRole bool\n+var flagCmdResetPassword bool\n+var flagConfigFile string\n+var flagEmail string\n+var flagPassword string\n+var flagTeamName string\n+var flagRole string\n+var flagRunCmds bool\n+\n func main() {\n \n-\tpwd, _ := os.Getwd()\n-\tfmt.Println(\"Current working directory is set to \" + pwd)\n+\tparseCmds()\n \n-\tvar config = flag.String(\"config\", \"config.json\", \"path to config file\")\n-\tflag.Parse()\n+\tutils.LoadConfig(flagConfigFile)\n+\n+\tif flagRunCmds {\n+\t\tutils.ConfigureCmdLineLog()\n+\t}\n+\n+\tpwd, _ := os.Getwd()\n+\tl4g.Info(\"Current working directory is %v\", pwd)\n+\tl4g.Info(\"Loaded config file from %v\", utils.FindConfigFile(flagConfigFile))\n \n-\tutils.LoadConfig(*config)\n \tapi.NewServer()\n \tapi.InitApi()\n \tweb.InitWeb()\n-\tapi.StartServer()\n \n-\t// If we allow testing then listen for manual testing URL hits\n-\tif utils.Cfg.ServiceSettings.AllowTesting {\n-\t\tmanualtesting.InitManualTesting()\n+\tif flagRunCmds {\n+\t\trunCmds()\n+\t} else {\n+\t\tapi.StartServer()\n+\n+\t\t// If we allow testing then listen for manual testing URL hits\n+\t\tif utils.Cfg.ServiceSettings.AllowTesting {\n+\t\t\tmanualtesting.InitManualTesting()\n+\t\t}\n+\n+\t\t// wait for kill signal before attempting to gracefully shutdown\n+\t\t// the running service\n+\t\tc := make(chan os.Signal)\n+\t\tsignal.Notify(c, os.Interrupt, syscall.SIGINT, syscall.SIGTERM)\n+\t\t<-c\n+\n+\t\tapi.StopServer()\n+\t}\n+}\n+\n+func parseCmds() {\n+\tflag.Usage = func() {\n+\t\tfmt.Fprintln(os.Stderr, usage)\n \t}\n \n-\t// wait for kill signal before attempting to gracefully shutdown\n-\t// the running service\n-\tc := make(chan os.Signal)\n-\tsignal.Notify(c, os.Interrupt, syscall.SIGINT, syscall.SIGTERM)\n-\t<-c\n+\tflag.StringVar(&flagConfigFile, \"config\", \"config.json\", \"\")\n+\tflag.StringVar(&flagEmail, \"email\", \"\", \"\")\n+\tflag.StringVar(&flagPassword, \"password\", \"\", \"\")\n+\tflag.StringVar(&flagTeamName, \"team_name\", \"\", \"\")\n+\tflag.StringVar(&flagRole, \"role\", \"\", \"\")\n \n-\tapi.StopServer()\n+\tflag.BoolVar(&flagCmdCreateTeam, \"create_team\", false, \"\")\n+\tflag.BoolVar(&flagCmdCreateUser, \"create_user\", false, \"\")\n+\tflag.BoolVar(&flagCmdAssignRole, \"assign_role\", false, \"\")\n+\tflag.BoolVar(&flagCmdResetPassword, \"reset_password\", false, \"\")\n+\n+\tflag.Parse()\n+\n+\tflagRunCmds = flagCmdCreateTeam || flagCmdCreateUser || flagCmdAssignRole || flagCmdResetPassword\n+}\n+\n+func runCmds() {\n+\tcmdCreateTeam()\n+\tcmdCreateUser()\n+\tcmdAssignRole()\n+\tcmdResetPassword()\n+}\n+\n+func cmdCreateTeam() {\n+\tif flagCmdCreateTeam {\n+\t\tif len(flagTeamName) == 0 {\n+\t\t\tfmt.Fprintln(os.Stderr, \"flag needs an argument: -team_name\")\n+\t\t\tflag.Usage()\n+\t\t\tos.Exit(1)\n+\t\t}\n+\n+\t\tif len(flagEmail) == 0 {\n+\t\t\tfmt.Fprintln(os.Stderr, \"flag needs an argument: -email\")\n+\t\t\tflag.Usage()\n+\t\t\tos.Exit(1)\n+\t\t}\n+\n+\t\tc := &api.Context{}\n+\t\tc.RequestId = model.NewId()\n+\t\tc.IpAddress = \"cmd_line\"\n+\n+\t\tteam := &model.Team{}\n+\t\tteam.DisplayName = flagTeamName\n+\t\tteam.Name = flagTeamName\n+\t\tteam.Email = flagEmail\n+\t\tteam.Type = model.TEAM_INVITE\n+\n+\t\tapi.CreateTeam(c, team)\n+\t\tif c.Err != nil {\n+\t\t\tif c.Err.Message != \"A team with that domain already exists\" {","path":"mattermost.go","position":139,"original_position":139,"commit_id":"41439eb801c6c8c0a55bcada3eeba3b4a561c663","original_commit_id":"41439eb801c6c8c0a55bcada3eeba3b4a561c663","user":{"login":"crspeller","id":3191642,"avatar_url":"https://avatars.githubusercontent.com/u/3191642?v=3","gravatar_id":"","url":"https://api.github.com/users/crspeller","html_url":"https://github.com/crspeller","followers_url":"https://api.github.com/users/crspeller/followers","following_url":"https://api.github.com/users/crspeller/following{/other_user}","gists_url":"https://api.github.com/users/crspeller/gists{/gist_id}","starred_url":"https://api.github.com/users/crspeller/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crspeller/subscriptions","organizations_url":"https://api.github.com/users/crspeller/orgs","repos_url":"https://api.github.com/users/crspeller/repos","events_url":"https://api.github.com/users/crspeller/events{/privacy}","received_events_url":"https://api.github.com/users/crspeller/received_events","type":"User","site_admin":false},"body":"Why do we ignore team name clashes? (also this error message should be updated)","created_at":"2015-09-11T11:53:27Z","updated_at":"2015-09-11T11:53:27Z","html_url":"https://github.com/mattermost/platform/pull/648#discussion_r39263658","pull_request_url":"https://api.github.com/repos/mattermost/platform/pulls/648","_links":{"self":{"href":"https://api.github.com/repos/mattermost/platform/pulls/comments/39263658"},"html":{"href":"https://github.com/mattermost/platform/pull/648#discussion_r39263658"},"pull_request":{"href":"https://api.github.com/repos/mattermost/platform/pulls/648"}}},"pull_request":{"url":"https://api.github.com/repos/mattermost/platform/pulls/648","id":44728750,"html_url":"https://github.com/mattermost/platform/pull/648","diff_url":"https://github.com/mattermost/platform/pull/648.diff","patch_url":"https://github.com/mattermost/platform/pull/648.patch","issue_url":"https://api.github.com/repos/mattermost/platform/issues/648","number":648,"state":"open","locked":false,"title":"PLT-12","user":{"login":"coreyhulen","id":1431746,"avatar_url":"https://avatars.githubusercontent.com/u/1431746?v=3","gravatar_id":"","url":"https://api.github.com/users/coreyhulen","html_url":"https://github.com/coreyhulen","followers_url":"https://api.github.com/users/coreyhulen/followers","following_url":"https://api.github.com/users/coreyhulen/following{/other_user}","gists_url":"https://api.github.com/users/coreyhulen/gists{/gist_id}","starred_url":"https://api.github.com/users/coreyhulen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coreyhulen/subscriptions","organizations_url":"https://api.github.com/users/coreyhulen/orgs","repos_url":"https://api.github.com/users/coreyhulen/repos","events_url":"https://api.github.com/users/coreyhulen/events{/privacy}","received_events_url":"https://api.github.com/users/coreyhulen/received_events","type":"User","site_admin":false},"body":"\r\nThis is a work in progress for the admin console UI.","created_at":"2015-09-10T22:45:21Z","updated_at":"2015-09-11T11:53:27Z","closed_at":null,"merged_at":null,"merge_commit_sha":"88ff940544462181f9b5f903f4a640764bbbdee5","assignee":{"login":"crspeller","id":3191642,"avatar_url":"https://avatars.githubusercontent.com/u/3191642?v=3","gravatar_id":"","url":"https://api.github.com/users/crspeller","html_url":"https://github.com/crspeller","followers_url":"https://api.github.com/users/crspeller/followers","following_url":"https://api.github.com/users/crspeller/following{/other_user}","gists_url":"https://api.github.com/users/crspeller/gists{/gist_id}","starred_url":"https://api.github.com/users/crspeller/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crspeller/subscriptions","organizations_url":"https://api.github.com/users/crspeller/orgs","repos_url":"https://api.github.com/users/crspeller/repos","events_url":"https://api.github.com/users/crspeller/events{/privacy}","received_events_url":"https://api.github.com/users/crspeller/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/mattermost/platform/milestones/3","html_url":"https://github.com/mattermost/platform/milestones/v0.8.0","labels_url":"https://api.github.com/repos/mattermost/platform/milestones/3/labels","id":1246518,"number":3,"title":"v0.8.0","description":"","creator":{"login":"it33","id":177788,"avatar_url":"https://avatars.githubusercontent.com/u/177788?v=3","gravatar_id":"","url":"https://api.github.com/users/it33","html_url":"https://github.com/it33","followers_url":"https://api.github.com/users/it33/followers","following_url":"https://api.github.com/users/it33/following{/other_user}","gists_url":"https://api.github.com/users/it33/gists{/gist_id}","starred_url":"https://api.github.com/users/it33/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/it33/subscriptions","organizations_url":"https://api.github.com/users/it33/orgs","repos_url":"https://api.github.com/users/it33/repos","events_url":"https://api.github.com/users/it33/events{/privacy}","received_events_url":"https://api.github.com/users/it33/received_events","type":"User","site_admin":false},"open_issues":3,"closed_issues":93,"state":"open","created_at":"2015-08-08T14:34:36Z","updated_at":"2015-09-11T11:43:10Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/mattermost/platform/pulls/648/commits","review_comments_url":"https://api.github.com/repos/mattermost/platform/pulls/648/comments","review_comment_url":"https://api.github.com/repos/mattermost/platform/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mattermost/platform/issues/648/comments","statuses_url":"https://api.github.com/repos/mattermost/platform/statuses/41439eb801c6c8c0a55bcada3eeba3b4a561c663","head":{"label":"mattermost:PLT-12","ref":"PLT-12","sha":"41439eb801c6c8c0a55bcada3eeba3b4a561c663","user":{"login":"mattermost","id":9828093,"avatar_url":"https://avatars.githubusercontent.com/u/9828093?v=3","gravatar_id":"","url":"https://api.github.com/users/mattermost","html_url":"https://github.com/mattermost","followers_url":"https://api.github.com/users/mattermost/followers","following_url":"https://api.github.com/users/mattermost/following{/other_user}","gists_url":"https://api.github.com/users/mattermost/gists{/gist_id}","starred_url":"https://api.github.com/users/mattermost/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mattermost/subscriptions","organizations_url":"https://api.github.com/users/mattermost/orgs","repos_url":"https://api.github.com/users/mattermost/repos","events_url":"https://api.github.com/users/mattermost/events{/privacy}","received_events_url":"https://api.github.com/users/mattermost/received_events","type":"Organization","site_admin":false},"repo":{"id":37448451,"name":"platform","full_name":"mattermost/platform","owner":{"login":"mattermost","id":9828093,"avatar_url":"https://avatars.githubusercontent.com/u/9828093?v=3","gravatar_id":"","url":"https://api.github.com/users/mattermost","html_url":"https://github.com/mattermost","followers_url":"https://api.github.com/users/mattermost/followers","following_url":"https://api.github.com/users/mattermost/following{/other_user}","gists_url":"https://api.github.com/users/mattermost/gists{/gist_id}","starred_url":"https://api.github.com/users/mattermost/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mattermost/subscriptions","organizations_url":"https://api.github.com/users/mattermost/orgs","repos_url":"https://api.github.com/users/mattermost/repos","events_url":"https://api.github.com/users/mattermost/events{/privacy}","received_events_url":"https://api.github.com/users/mattermost/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mattermost/platform","description":"Open source Slack-alternative in Golang and React","fork":false,"url":"https://api.github.com/repos/mattermost/platform","forks_url":"https://api.github.com/repos/mattermost/platform/forks","keys_url":"https://api.github.com/repos/mattermost/platform/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mattermost/platform/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mattermost/platform/teams","hooks_url":"https://api.github.com/repos/mattermost/platform/hooks","issue_events_url":"https://api.github.com/repos/mattermost/platform/issues/events{/number}","events_url":"https://api.github.com/repos/mattermost/platform/events","assignees_url":"https://api.github.com/repos/mattermost/platform/assignees{/user}","branches_url":"https://api.github.com/repos/mattermost/platform/branches{/branch}","tags_url":"https://api.github.com/repos/mattermost/platform/tags","blobs_url":"https://api.github.com/repos/mattermost/platform/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mattermost/platform/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mattermost/platform/git/refs{/sha}","trees_url":"https://api.github.com/repos/mattermost/platform/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mattermost/platform/statuses/{sha}","languages_url":"https://api.github.com/repos/mattermost/platform/languages","stargazers_url":"https://api.github.com/repos/mattermost/platform/stargazers","contributors_url":"https://api.github.com/repos/mattermost/platform/contributors","subscribers_url":"https://api.github.com/repos/mattermost/platform/subscribers","subscription_url":"https://api.github.com/repos/mattermost/platform/subscription","commits_url":"https://api.github.com/repos/mattermost/platform/commits{/sha}","git_commits_url":"https://api.github.com/repos/mattermost/platform/git/commits{/sha}","comments_url":"https://api.github.com/repos/mattermost/platform/comments{/number}","issue_comment_url":"https://api.github.com/repos/mattermost/platform/issues/comments{/number}","contents_url":"https://api.github.com/repos/mattermost/platform/contents/{+path}","compare_url":"https://api.github.com/repos/mattermost/platform/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mattermost/platform/merges","archive_url":"https://api.github.com/repos/mattermost/platform/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mattermost/platform/downloads","issues_url":"https://api.github.com/repos/mattermost/platform/issues{/number}","pulls_url":"https://api.github.com/repos/mattermost/platform/pulls{/number}","milestones_url":"https://api.github.com/repos/mattermost/platform/milestones{/number}","notifications_url":"https://api.github.com/repos/mattermost/platform/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mattermost/platform/labels{/name}","releases_url":"https://api.github.com/repos/mattermost/platform/releases{/id}","created_at":"2015-06-15T06:50:02Z","updated_at":"2015-09-11T11:15:34Z","pushed_at":"2015-09-11T11:43:10Z","git_url":"git://github.com/mattermost/platform.git","ssh_url":"git@github.com:mattermost/platform.git","clone_url":"https://github.com/mattermost/platform.git","svn_url":"https://github.com/mattermost/platform","homepage":"http://mattermost.org","size":14844,"stargazers_count":3003,"watchers_count":3003,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":253,"mirror_url":null,"open_issues_count":14,"forks":253,"open_issues":14,"watchers":3003,"default_branch":"master"}},"base":{"label":"mattermost:master","ref":"master","sha":"927b474005b9e6c03f7385f4d1a06626dd0450e3","user":{"login":"mattermost","id":9828093,"avatar_url":"https://avatars.githubusercontent.com/u/9828093?v=3","gravatar_id":"","url":"https://api.github.com/users/mattermost","html_url":"https://github.com/mattermost","followers_url":"https://api.github.com/users/mattermost/followers","following_url":"https://api.github.com/users/mattermost/following{/other_user}","gists_url":"https://api.github.com/users/mattermost/gists{/gist_id}","starred_url":"https://api.github.com/users/mattermost/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mattermost/subscriptions","organizations_url":"https://api.github.com/users/mattermost/orgs","repos_url":"https://api.github.com/users/mattermost/repos","events_url":"https://api.github.com/users/mattermost/events{/privacy}","received_events_url":"https://api.github.com/users/mattermost/received_events","type":"Organization","site_admin":false},"repo":{"id":37448451,"name":"platform","full_name":"mattermost/platform","owner":{"login":"mattermost","id":9828093,"avatar_url":"https://avatars.githubusercontent.com/u/9828093?v=3","gravatar_id":"","url":"https://api.github.com/users/mattermost","html_url":"https://github.com/mattermost","followers_url":"https://api.github.com/users/mattermost/followers","following_url":"https://api.github.com/users/mattermost/following{/other_user}","gists_url":"https://api.github.com/users/mattermost/gists{/gist_id}","starred_url":"https://api.github.com/users/mattermost/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mattermost/subscriptions","organizations_url":"https://api.github.com/users/mattermost/orgs","repos_url":"https://api.github.com/users/mattermost/repos","events_url":"https://api.github.com/users/mattermost/events{/privacy}","received_events_url":"https://api.github.com/users/mattermost/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mattermost/platform","description":"Open source Slack-alternative in Golang and React","fork":false,"url":"https://api.github.com/repos/mattermost/platform","forks_url":"https://api.github.com/repos/mattermost/platform/forks","keys_url":"https://api.github.com/repos/mattermost/platform/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mattermost/platform/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mattermost/platform/teams","hooks_url":"https://api.github.com/repos/mattermost/platform/hooks","issue_events_url":"https://api.github.com/repos/mattermost/platform/issues/events{/number}","events_url":"https://api.github.com/repos/mattermost/platform/events","assignees_url":"https://api.github.com/repos/mattermost/platform/assignees{/user}","branches_url":"https://api.github.com/repos/mattermost/platform/branches{/branch}","tags_url":"https://api.github.com/repos/mattermost/platform/tags","blobs_url":"https://api.github.com/repos/mattermost/platform/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mattermost/platform/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mattermost/platform/git/refs{/sha}","trees_url":"https://api.github.com/repos/mattermost/platform/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mattermost/platform/statuses/{sha}","languages_url":"https://api.github.com/repos/mattermost/platform/languages","stargazers_url":"https://api.github.com/repos/mattermost/platform/stargazers","contributors_url":"https://api.github.com/repos/mattermost/platform/contributors","subscribers_url":"https://api.github.com/repos/mattermost/platform/subscribers","subscription_url":"https://api.github.com/repos/mattermost/platform/subscription","commits_url":"https://api.github.com/repos/mattermost/platform/commits{/sha}","git_commits_url":"https://api.github.com/repos/mattermost/platform/git/commits{/sha}","comments_url":"https://api.github.com/repos/mattermost/platform/comments{/number}","issue_comment_url":"https://api.github.com/repos/mattermost/platform/issues/comments{/number}","contents_url":"https://api.github.com/repos/mattermost/platform/contents/{+path}","compare_url":"https://api.github.com/repos/mattermost/platform/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mattermost/platform/merges","archive_url":"https://api.github.com/repos/mattermost/platform/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mattermost/platform/downloads","issues_url":"https://api.github.com/repos/mattermost/platform/issues{/number}","pulls_url":"https://api.github.com/repos/mattermost/platform/pulls{/number}","milestones_url":"https://api.github.com/repos/mattermost/platform/milestones{/number}","notifications_url":"https://api.github.com/repos/mattermost/platform/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mattermost/platform/labels{/name}","releases_url":"https://api.github.com/repos/mattermost/platform/releases{/id}","created_at":"2015-06-15T06:50:02Z","updated_at":"2015-09-11T11:15:34Z","pushed_at":"2015-09-11T11:43:10Z","git_url":"git://github.com/mattermost/platform.git","ssh_url":"git@github.com:mattermost/platform.git","clone_url":"https://github.com/mattermost/platform.git","svn_url":"https://github.com/mattermost/platform","homepage":"http://mattermost.org","size":14844,"stargazers_count":3003,"watchers_count":3003,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":253,"mirror_url":null,"open_issues_count":14,"forks":253,"open_issues":14,"watchers":3003,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mattermost/platform/pulls/648"},"html":{"href":"https://github.com/mattermost/platform/pull/648"},"issue":{"href":"https://api.github.com/repos/mattermost/platform/issues/648"},"comments":{"href":"https://api.github.com/repos/mattermost/platform/issues/648/comments"},"review_comments":{"href":"https://api.github.com/repos/mattermost/platform/pulls/648/comments"},"review_comment":{"href":"https://api.github.com/repos/mattermost/platform/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mattermost/platform/pulls/648/commits"},"statuses":{"href":"https://api.github.com/repos/mattermost/platform/statuses/41439eb801c6c8c0a55bcada3eeba3b4a561c663"}}}}