{"action":"created","comment":{"url":"https://api.github.com/repos/TuneLab/go-truss/pulls/comments/82898709","pull_request_review_id":3773909,"id":82898709,"diff_hunk":"@@ -6,133 +6,209 @@ import (\n \t\"io\"\n \t\"io/ioutil\"\n \t\"os\"\n-\t\"path\"\n \t\"path/filepath\"\n \t\"strings\"\n \n \t\"github.com/pkg/errors\"\n \n-\t\"github.com/TuneLab/go-truss/truss/protostage\"\n+\t\"github.com/TuneLab/go-truss/truss/protostuff\"\n \t\"github.com/TuneLab/go-truss/truss/truss\"\n \n \t\"github.com/TuneLab/go-truss/deftree\"\n \t\"github.com/TuneLab/go-truss/gendoc\"\n \t\"github.com/TuneLab/go-truss/gengokit\"\n )\n \n-func main() {\n+var (\n+\tpbPathFlag = flag.String(\"pbout\", \"\", \"The go package path where the protoc-gen-go .pb.go structs will be written.\")\n+)\n+\n+func init() {\n+\tflag.Usage = func() {\n+\t\tfmt.Fprintf(os.Stderr, \"Usage: %s [OPTION]... [*.proto]...\\n\", os.Args[0])\n+\t\tflag.PrintDefaults()\n+\t}\n+\n \tflag.Parse()\n \n \tif len(flag.Args()) == 0 {\n-\t\texitIfError(errors.New(\"no arguments passed\"))\n+\t\tfmt.Fprintf(os.Stderr, \"%s: missing .proto file(s)\\n\", os.Args[0])\n+\t\tfmt.Fprintf(os.Stderr, \"Try '%s --help' for more information.\\n\", os.Args[0])\n+\t\tos.Exit(1)\n \t}\n+}\n+\n+func main() {\n+\tcfg, err := parseInput()\n+\texitIfError(errors.Wrap(err, \"could not parse input\"))\n+\n+\tdt, err := parseServiceDefinition(cfg.DefPaths)\n+\texitIfError(errors.Wrap(err, \"unable to parse input definition proto files\"))\n+\n+\terr = updateConfigWithService(cfg, dt)\n+\texitIfError(errors.Wrap(err, \"unable to read system based on service definition\"))\n+\n+\tgenFiles, err := generateCode(cfg, dt)\n+\texitIfError(errors.Wrap(err, \"unable to generate service\"))\n \n+\tfor _, f := range genFiles {\n+\t\terr := writeGenFile(f, cfg.ServicePath)\n+\t\tif err != nil {\n+\t\t\texitIfError(errors.Wrap(err, \"unable to write output\"))\n+\t\t}\n+\t}\n+}\n+\n+// parseInput constructs a *truss.Config with all values needed to parse\n+// service definition files.\n+func parseInput() (*truss.Config, error) {\n+\tvar cfg truss.Config\n+\n+\t// GOPATH\n+\tgoPaths := filepath.SplitList(os.Getenv(\"GOPATH\"))\n+\tif goPaths == nil {\n+\t\treturn nil, errors.New(\"$GOPATH not set\")\n+\t}\n+\tcfg.GOPATH = goPaths[0]\n+\n+\t// DefPaths\n+\tvar err error\n \trawDefinitionPaths := flag.Args()\n+\tcfg.DefPaths, err = cleanProtofilePath(rawDefinitionPaths)\n+\tif err != nil {\n+\t\treturn nil, errors.Wrap(err, \"unable to parse input arguments\")\n+\t}\n \n-\tprotoDir, definitionFiles, err := cleanProtofilePath(rawDefinitionPaths)\n+\t// PBGoPath\n+\tif *pbPathFlag != \"\" {","path":"truss/main.go","position":83,"original_position":83,"commit_id":"e765fa9d0e4889468a088fac5710aa19205d7383","original_commit_id":"e765fa9d0e4889468a088fac5710aa19205d7383","user":{"login":"hasAdamr","id":19537819,"avatar_url":"https://avatars.githubusercontent.com/u/19537819?v=3","gravatar_id":"","url":"https://api.github.com/users/hasAdamr","html_url":"https://github.com/hasAdamr","followers_url":"https://api.github.com/users/hasAdamr/followers","following_url":"https://api.github.com/users/hasAdamr/following{/other_user}","gists_url":"https://api.github.com/users/hasAdamr/gists{/gist_id}","starred_url":"https://api.github.com/users/hasAdamr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hasAdamr/subscriptions","organizations_url":"https://api.github.com/users/hasAdamr/orgs","repos_url":"https://api.github.com/users/hasAdamr/repos","events_url":"https://api.github.com/users/hasAdamr/events{/privacy}","received_events_url":"https://api.github.com/users/hasAdamr/received_events","type":"User","site_admin":false},"body":"I personally like the inversion, flattens things out even if the return is repeated. \r\n\r\nI chose all caps for `GOPATH` because that is what it is called in the go build context struct: https://github.com/golang/go/blob/master/src/go/build/build.go#L34","created_at":"2016-10-11T21:59:56Z","updated_at":"2016-10-11T21:59:56Z","html_url":"https://github.com/TuneLab/go-truss/pull/70#discussion_r82898709","pull_request_url":"https://api.github.com/repos/TuneLab/go-truss/pulls/70","_links":{"self":{"href":"https://api.github.com/repos/TuneLab/go-truss/pulls/comments/82898709"},"html":{"href":"https://github.com/TuneLab/go-truss/pull/70#discussion_r82898709"},"pull_request":{"href":"https://api.github.com/repos/TuneLab/go-truss/pulls/70"}}},"pull_request":{"url":"https://api.github.com/repos/TuneLab/go-truss/pulls/70","id":88909220,"html_url":"https://github.com/TuneLab/go-truss/pull/70","diff_url":"https://github.com/TuneLab/go-truss/pull/70.diff","patch_url":"https://github.com/TuneLab/go-truss/pull/70.patch","issue_url":"https://api.github.com/repos/TuneLab/go-truss/issues/70","number":70,"state":"open","locked":false,"title":"Add -pbout flag for .pb.go out directory; Large refactor for pipeline changes.","user":{"login":"hasAdamr","id":19537819,"avatar_url":"https://avatars.githubusercontent.com/u/19537819?v=3","gravatar_id":"","url":"https://api.github.com/users/hasAdamr","html_url":"https://github.com/hasAdamr","followers_url":"https://api.github.com/users/hasAdamr/followers","following_url":"https://api.github.com/users/hasAdamr/following{/other_user}","gists_url":"https://api.github.com/users/hasAdamr/gists{/gist_id}","starred_url":"https://api.github.com/users/hasAdamr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hasAdamr/subscriptions","organizations_url":"https://api.github.com/users/hasAdamr/orgs","repos_url":"https://api.github.com/users/hasAdamr/repos","events_url":"https://api.github.com/users/hasAdamr/events{/privacy}","received_events_url":"https://api.github.com/users/hasAdamr/received_events","type":"User","site_admin":false},"body":"The -pbout flag has been added to specify a go package path to write the .pb.go files to. There is a cli test for this functionality.\r\n\r\nNote that the imports in the handler files will not be updated if regenerated with a new -pbout flag. Also the -pbout flag must be used with the same package for each invoking of truss to keep the .pb.go files in that directory.\r\n\r\nUseful information now prints when invoking truss without arguments, inspired by `cp` and `mv`.\r\n\r\nIn addition I have completely re-factored [`main.go`](https://github.com/hasAdamr/go-truss/blob/e765fa9d0e4889468a088fac5710aa19205d7383/truss/main.go) and [`protostage.go->protostuff.go`](https://github.com/hasAdamr/go-truss/blob/e765fa9d0e4889468a088fac5710aa19205d7383/truss/protostuff/protostuff.go). For `main.go` it will be hard to read the diff so I recommend just looking at the new file.\r\n\r\nThis refactoring was done to make it easier to add the -pbout flag, but also to have the code follow the flow for other cli programs such as `go build` and `go-bindata`.\r\n\r\nFinally this refactoring was done in preparation for updating the pipeline with @hasLeland's .pb.go parser for a much more robust type system.","created_at":"2016-10-11T20:54:13Z","updated_at":"2016-10-11T21:59:56Z","closed_at":null,"merged_at":null,"merge_commit_sha":"716715c10dc0406b7541502c3ea4bf2fec6ff97d","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/TuneLab/go-truss/pulls/70/commits","review_comments_url":"https://api.github.com/repos/TuneLab/go-truss/pulls/70/comments","review_comment_url":"https://api.github.com/repos/TuneLab/go-truss/pulls/comments{/number}","comments_url":"https://api.github.com/repos/TuneLab/go-truss/issues/70/comments","statuses_url":"https://api.github.com/repos/TuneLab/go-truss/statuses/e765fa9d0e4889468a088fac5710aa19205d7383","head":{"label":"hasAdamr:refactor-protostage","ref":"refactor-protostage","sha":"e765fa9d0e4889468a088fac5710aa19205d7383","user":{"login":"hasAdamr","id":19537819,"avatar_url":"https://avatars.githubusercontent.com/u/19537819?v=3","gravatar_id":"","url":"https://api.github.com/users/hasAdamr","html_url":"https://github.com/hasAdamr","followers_url":"https://api.github.com/users/hasAdamr/followers","following_url":"https://api.github.com/users/hasAdamr/following{/other_user}","gists_url":"https://api.github.com/users/hasAdamr/gists{/gist_id}","starred_url":"https://api.github.com/users/hasAdamr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hasAdamr/subscriptions","organizations_url":"https://api.github.com/users/hasAdamr/orgs","repos_url":"https://api.github.com/users/hasAdamr/repos","events_url":"https://api.github.com/users/hasAdamr/events{/privacy}","received_events_url":"https://api.github.com/users/hasAdamr/received_events","type":"User","site_admin":false},"repo":{"id":66120508,"name":"go-truss","full_name":"hasAdamr/go-truss","owner":{"login":"hasAdamr","id":19537819,"avatar_url":"https://avatars.githubusercontent.com/u/19537819?v=3","gravatar_id":"","url":"https://api.github.com/users/hasAdamr","html_url":"https://github.com/hasAdamr","followers_url":"https://api.github.com/users/hasAdamr/followers","following_url":"https://api.github.com/users/hasAdamr/following{/other_user}","gists_url":"https://api.github.com/users/hasAdamr/gists{/gist_id}","starred_url":"https://api.github.com/users/hasAdamr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hasAdamr/subscriptions","organizations_url":"https://api.github.com/users/hasAdamr/orgs","repos_url":"https://api.github.com/users/hasAdamr/repos","events_url":"https://api.github.com/users/hasAdamr/events{/privacy}","received_events_url":"https://api.github.com/users/hasAdamr/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/hasAdamr/go-truss","description":"Truss helps you build go-kit microservices without having to worry about writing or maintaining boilerplate code.","fork":true,"url":"https://api.github.com/repos/hasAdamr/go-truss","forks_url":"https://api.github.com/repos/hasAdamr/go-truss/forks","keys_url":"https://api.github.com/repos/hasAdamr/go-truss/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hasAdamr/go-truss/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hasAdamr/go-truss/teams","hooks_url":"https://api.github.com/repos/hasAdamr/go-truss/hooks","issue_events_url":"https://api.github.com/repos/hasAdamr/go-truss/issues/events{/number}","events_url":"https://api.github.com/repos/hasAdamr/go-truss/events","assignees_url":"https://api.github.com/repos/hasAdamr/go-truss/assignees{/user}","branches_url":"https://api.github.com/repos/hasAdamr/go-truss/branches{/branch}","tags_url":"https://api.github.com/repos/hasAdamr/go-truss/tags","blobs_url":"https://api.github.com/repos/hasAdamr/go-truss/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hasAdamr/go-truss/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hasAdamr/go-truss/git/refs{/sha}","trees_url":"https://api.github.com/repos/hasAdamr/go-truss/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hasAdamr/go-truss/statuses/{sha}","languages_url":"https://api.github.com/repos/hasAdamr/go-truss/languages","stargazers_url":"https://api.github.com/repos/hasAdamr/go-truss/stargazers","contributors_url":"https://api.github.com/repos/hasAdamr/go-truss/contributors","subscribers_url":"https://api.github.com/repos/hasAdamr/go-truss/subscribers","subscription_url":"https://api.github.com/repos/hasAdamr/go-truss/subscription","commits_url":"https://api.github.com/repos/hasAdamr/go-truss/commits{/sha}","git_commits_url":"https://api.github.com/repos/hasAdamr/go-truss/git/commits{/sha}","comments_url":"https://api.github.com/repos/hasAdamr/go-truss/comments{/number}","issue_comment_url":"https://api.github.com/repos/hasAdamr/go-truss/issues/comments{/number}","contents_url":"https://api.github.com/repos/hasAdamr/go-truss/contents/{+path}","compare_url":"https://api.github.com/repos/hasAdamr/go-truss/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hasAdamr/go-truss/merges","archive_url":"https://api.github.com/repos/hasAdamr/go-truss/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hasAdamr/go-truss/downloads","issues_url":"https://api.github.com/repos/hasAdamr/go-truss/issues{/number}","pulls_url":"https://api.github.com/repos/hasAdamr/go-truss/pulls{/number}","milestones_url":"https://api.github.com/repos/hasAdamr/go-truss/milestones{/number}","notifications_url":"https://api.github.com/repos/hasAdamr/go-truss/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hasAdamr/go-truss/labels{/name}","releases_url":"https://api.github.com/repos/hasAdamr/go-truss/releases{/id}","deployments_url":"https://api.github.com/repos/hasAdamr/go-truss/deployments","created_at":"2016-08-20T00:38:18Z","updated_at":"2016-08-20T00:38:20Z","pushed_at":"2016-10-11T19:50:50Z","git_url":"git://github.com/hasAdamr/go-truss.git","ssh_url":"git@github.com:hasAdamr/go-truss.git","clone_url":"https://github.com/hasAdamr/go-truss.git","svn_url":"https://github.com/hasAdamr/go-truss","homepage":"","size":10072,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"TuneLab:master","ref":"master","sha":"a2bd9bc5482e50ee2a70d19494bf4fcfc9ea880e","user":{"login":"TuneLab","id":12895637,"avatar_url":"https://avatars.githubusercontent.com/u/12895637?v=3","gravatar_id":"","url":"https://api.github.com/users/TuneLab","html_url":"https://github.com/TuneLab","followers_url":"https://api.github.com/users/TuneLab/followers","following_url":"https://api.github.com/users/TuneLab/following{/other_user}","gists_url":"https://api.github.com/users/TuneLab/gists{/gist_id}","starred_url":"https://api.github.com/users/TuneLab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TuneLab/subscriptions","organizations_url":"https://api.github.com/users/TuneLab/orgs","repos_url":"https://api.github.com/users/TuneLab/repos","events_url":"https://api.github.com/users/TuneLab/events{/privacy}","received_events_url":"https://api.github.com/users/TuneLab/received_events","type":"Organization","site_admin":false},"repo":{"id":61059364,"name":"go-truss","full_name":"TuneLab/go-truss","owner":{"login":"TuneLab","id":12895637,"avatar_url":"https://avatars.githubusercontent.com/u/12895637?v=3","gravatar_id":"","url":"https://api.github.com/users/TuneLab","html_url":"https://github.com/TuneLab","followers_url":"https://api.github.com/users/TuneLab/followers","following_url":"https://api.github.com/users/TuneLab/following{/other_user}","gists_url":"https://api.github.com/users/TuneLab/gists{/gist_id}","starred_url":"https://api.github.com/users/TuneLab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TuneLab/subscriptions","organizations_url":"https://api.github.com/users/TuneLab/orgs","repos_url":"https://api.github.com/users/TuneLab/repos","events_url":"https://api.github.com/users/TuneLab/events{/privacy}","received_events_url":"https://api.github.com/users/TuneLab/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/TuneLab/go-truss","description":"Truss helps you build go-kit microservices without having to worry about writing or maintaining boilerplate code.","fork":false,"url":"https://api.github.com/repos/TuneLab/go-truss","forks_url":"https://api.github.com/repos/TuneLab/go-truss/forks","keys_url":"https://api.github.com/repos/TuneLab/go-truss/keys{/key_id}","collaborators_url":"https://api.github.com/repos/TuneLab/go-truss/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/TuneLab/go-truss/teams","hooks_url":"https://api.github.com/repos/TuneLab/go-truss/hooks","issue_events_url":"https://api.github.com/repos/TuneLab/go-truss/issues/events{/number}","events_url":"https://api.github.com/repos/TuneLab/go-truss/events","assignees_url":"https://api.github.com/repos/TuneLab/go-truss/assignees{/user}","branches_url":"https://api.github.com/repos/TuneLab/go-truss/branches{/branch}","tags_url":"https://api.github.com/repos/TuneLab/go-truss/tags","blobs_url":"https://api.github.com/repos/TuneLab/go-truss/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/TuneLab/go-truss/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/TuneLab/go-truss/git/refs{/sha}","trees_url":"https://api.github.com/repos/TuneLab/go-truss/git/trees{/sha}","statuses_url":"https://api.github.com/repos/TuneLab/go-truss/statuses/{sha}","languages_url":"https://api.github.com/repos/TuneLab/go-truss/languages","stargazers_url":"https://api.github.com/repos/TuneLab/go-truss/stargazers","contributors_url":"https://api.github.com/repos/TuneLab/go-truss/contributors","subscribers_url":"https://api.github.com/repos/TuneLab/go-truss/subscribers","subscription_url":"https://api.github.com/repos/TuneLab/go-truss/subscription","commits_url":"https://api.github.com/repos/TuneLab/go-truss/commits{/sha}","git_commits_url":"https://api.github.com/repos/TuneLab/go-truss/git/commits{/sha}","comments_url":"https://api.github.com/repos/TuneLab/go-truss/comments{/number}","issue_comment_url":"https://api.github.com/repos/TuneLab/go-truss/issues/comments{/number}","contents_url":"https://api.github.com/repos/TuneLab/go-truss/contents/{+path}","compare_url":"https://api.github.com/repos/TuneLab/go-truss/compare/{base}...{head}","merges_url":"https://api.github.com/repos/TuneLab/go-truss/merges","archive_url":"https://api.github.com/repos/TuneLab/go-truss/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/TuneLab/go-truss/downloads","issues_url":"https://api.github.com/repos/TuneLab/go-truss/issues{/number}","pulls_url":"https://api.github.com/repos/TuneLab/go-truss/pulls{/number}","milestones_url":"https://api.github.com/repos/TuneLab/go-truss/milestones{/number}","notifications_url":"https://api.github.com/repos/TuneLab/go-truss/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/TuneLab/go-truss/labels{/name}","releases_url":"https://api.github.com/repos/TuneLab/go-truss/releases{/id}","deployments_url":"https://api.github.com/repos/TuneLab/go-truss/deployments","created_at":"2016-06-13T18:18:25Z","updated_at":"2016-10-10T00:35:58Z","pushed_at":"2016-10-11T21:18:30Z","git_url":"git://github.com/TuneLab/go-truss.git","ssh_url":"git@github.com:TuneLab/go-truss.git","clone_url":"https://github.com/TuneLab/go-truss.git","svn_url":"https://github.com/TuneLab/go-truss","homepage":"","size":10060,"stargazers_count":27,"watchers_count":27,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":7,"mirror_url":null,"open_issues_count":10,"forks":7,"open_issues":10,"watchers":27,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/TuneLab/go-truss/pulls/70"},"html":{"href":"https://github.com/TuneLab/go-truss/pull/70"},"issue":{"href":"https://api.github.com/repos/TuneLab/go-truss/issues/70"},"comments":{"href":"https://api.github.com/repos/TuneLab/go-truss/issues/70/comments"},"review_comments":{"href":"https://api.github.com/repos/TuneLab/go-truss/pulls/70/comments"},"review_comment":{"href":"https://api.github.com/repos/TuneLab/go-truss/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/TuneLab/go-truss/pulls/70/commits"},"statuses":{"href":"https://api.github.com/repos/TuneLab/go-truss/statuses/e765fa9d0e4889468a088fac5710aa19205d7383"}}}}
{"actor":{"display_login":"hasAdamr"}}