GitHub PullRequestReviewCommentEvent at 2014-11-09 11:50:06
Repository: go-ipfs
Actor: jbenet
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/jbenet/go-ipfs/pulls/comments/20058279","id":20058279,"diff_hunk":"@@ -0,0 +1,196 @@\n+package cli\n+\n+import (\n+\t\"fmt\"\n+\t\"strings\"\n+\n+\tcmds \"github.com/jbenet/go-ipfs/commands\"\n+)\n+\n+const (\n+\trequiredArg = \"<%v>\"\n+\toptionalArg = \"[<%v>]\"\n+\tvariadicArg = \"%v...\"\n+\toptionFlag  = \"-%v\"\n+\toptionType  = \"(%v)\"\n+\n+\twhitespace = \"\\r\\n\\t \"\n+)\n+\n+// HelpText returns a formatted CLI helptext string, generated for the given command\n+func HelpText(rootName string, root *cmds.Command, path []string) (string, error) {\n+\tcmd, err := root.Get(path)\n+\tif err != nil {\n+\t\treturn \"\", err\n+\t}\n+\n+\ts := \"\"\n+\tusage := usageText(cmd)\n+\tif len(usage) > 0 {\n+\t\tusage += \" \"\n+\t}\n+\ts += fmt.Sprintf(\"%v %v %v- %v\\n\\n\", rootName, strings.Join(path, \" \"), usage, cmd.Description)\n+\n+\tif len(cmd.Help) > 0 {\n+\t\ts += fmt.Sprintf(\"%v\\n\\n\", strings.Trim(cmd.Help, whitespace))\n+\t}\n+\n+\tif cmd.Arguments != nil {\n+\t\tlines := indent(argumentText(cmd), \"  \")\n+\t\ts += fmt.Sprintf(\"Arguments:\\n%v\\n\\n\", strings.Join(lines, \"\\n\"))\n+\t}\n+\n+\tif cmd.Subcommands != nil {\n+\t\tlines := indent(subcommandText(cmd, rootName, path), \"  \")\n+\t\ts += fmt.Sprintf(\"Subcommands:\\n%v\\n\\n\", strings.Join(lines, \"\\n\"))\n+\t}\n+\n+\tif cmd.Options != nil {\n+\t\tlines := indent(optionText(cmd), \"  \")\n+\t\ts += fmt.Sprintf(\"Options:\\n%v\\n\\n\", strings.Join(lines, \"\\n\"))\n+\t}\n+\n+\treturn s, nil\n+}\n+\n+func argumentText(cmd *cmds.Command) []string {\n+\tlines := make([]string, len(cmd.Arguments))\n+\n+\tfor i, arg := range cmd.Arguments {\n+\t\tlines[i] = argUsageText(arg)\n+\t\tlines[i] += \"\\n\" + arg.Description\n+\t\tlines[i] = indentString(lines[i], \"    \") + \"\\n\"\n+\t}\n+\n+\treturn lines\n+}\n+\n+func optionText(cmd ...*cmds.Command) []string {\n+\t// get a slice of the options we want to list out\n+\toptions := make([]cmds.Option, 0)\n+\tfor _, c := range cmd {\n+\t\tfor _, opt := range c.Options {\n+\t\t\toptions = append(options, opt)\n+\t\t}\n+\t}\n+\n+\t// add option names to output (with each name aligned)\n+\tlines := make([]string, 0)\n+\tj := 0\n+\tfor {\n+\t\tdone := true\n+\t\ti := 0\n+\t\tfor _, opt := range options {\n+\t\t\tif len(lines) < i+1 {\n+\t\t\t\tlines = append(lines, \"\")\n+\t\t\t}\n+\t\t\tif len(opt.Names) >= j+1 {\n+\t\t\t\tlines[i] += fmt.Sprintf(optionFlag, opt.Names[j])\n+\t\t\t}\n+\t\t\tif len(opt.Names) > j+1 {\n+\t\t\t\tlines[i] += \", \"\n+\t\t\t\tdone = false\n+\t\t\t}\n+\n+\t\t\ti++\n+\t\t}\n+\n+\t\tif done {\n+\t\t\tbreak\n+\t\t}\n+\n+\t\tlines = align(lines)\n+\t\tj++\n+\t}\n+\n+\t// add option types to output\n+\tfor i, opt := range options {\n+\t\tlines[i] += \" \" + fmt.Sprintf(optionType, opt.Type)\n+\t}\n+\tlines = align(lines)\n+\n+\t// add option descriptions to output\n+\tfor i, opt := range options {\n+\t\tlines[i] += \"\\n\" + opt.Description\n+\t\tlines[i] = indentString(lines[i], \"    \") + \"\\n\"\n+\t}\n+\n+\treturn lines\n+}\n+\n+func subcommandText(cmd *cmds.Command, rootName string, path []string) []string {\n+\tprefix := fmt.Sprintf(\"%v %v\", rootName, strings.Join(path, \" \"))\n+\tif len(path) > 0 {\n+\t\tprefix += \" \"\n+\t}\n+\tlines := make([]string, len(cmd.Subcommands))\n+\n+\ti := 0\n+\tfor name, sub := range cmd.Subcommands {\n+\t\tusage := usageText(sub)\n+\t\tlines[i] = fmt.Sprintf(\"%v%v %v\", prefix, name, usage)\n+\t\tlines[i] += fmt.Sprintf(\"\\n%v\", sub.Description)\n+\t\tlines[i] = indentString(lines[i], \"    \") + \"\\n\"\n+\t\ti++\n+\t}\n+\n+\treturn lines\n+}\n+\n+func usageText(cmd *cmds.Command) string {\n+\ts := \"\"\n+\tfor i, arg := range cmd.Arguments {\n+\t\tif i != 0 {\n+\t\t\ts += \" \"\n+\t\t}\n+\t\ts += argUsageText(arg)\n+\t}\n+\n+\treturn s\n+}\n+\n+func argUsageText(arg cmds.Argument) string {\n+\ts := arg.Name\n+\n+\tif arg.Required {\n+\t\ts = fmt.Sprintf(requiredArg, s)\n+\t} else {\n+\t\ts = fmt.Sprintf(optionalArg, s)\n+\t}\n+\n+\tif arg.Variadic {\n+\t\ts = fmt.Sprintf(variadicArg, s)\n+\t}\n+\n+\treturn s\n+}","path":"commands/cli/helptext.go","position":166,"original_position":166,"commit_id":"418ae0bd0f76c808055c76685bdeab94d5e59a72","original_commit_id":"030ff17d73b2d3cf2509b379764fa491bf68ff59","user":{"login":"jbenet","id":138401,"avatar_url":"https://avatars.githubusercontent.com/u/138401?v=3","gravatar_id":"","url":"https://api.github.com/users/jbenet","html_url":"https://github.com/jbenet","followers_url":"https://api.github.com/users/jbenet/followers","following_url":"https://api.github.com/users/jbenet/following{/other_user}","gists_url":"https://api.github.com/users/jbenet/gists{/gist_id}","starred_url":"https://api.github.com/users/jbenet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jbenet/subscriptions","organizations_url":"https://api.github.com/users/jbenet/orgs","repos_url":"https://api.github.com/users/jbenet/repos","events_url":"https://api.github.com/users/jbenet/events{/privacy}","received_events_url":"https://api.github.com/users/jbenet/received_events","type":"User","site_admin":false},"body":"templates","created_at":"2014-11-09T11:50:06Z","updated_at":"2014-11-09T11:50:06Z","html_url":"https://github.com/jbenet/go-ipfs/pull/263#discussion_r20058279","pull_request_url":"https://api.github.com/repos/jbenet/go-ipfs/pulls/263","_links":{"self":{"href":"https://api.github.com/repos/jbenet/go-ipfs/pulls/comments/20058279"},"html":{"href":"https://github.com/jbenet/go-ipfs/pull/263#discussion_r20058279"},"pull_request":{"href":"https://api.github.com/repos/jbenet/go-ipfs/pulls/263"}}},"pull_request":{"url":"https://api.github.com/repos/jbenet/go-ipfs/pulls/263","id":23820883,"html_url":"https://github.com/jbenet/go-ipfs/pull/263","diff_url":"https://github.com/jbenet/go-ipfs/pull/263.diff","patch_url":"https://github.com/jbenet/go-ipfs/pull/263.patch","issue_url":"https://api.github.com/repos/jbenet/go-ipfs/issues/263","number":263,"state":"open","locked":false,"title":"Commands Refactor Part 2","user":{"login":"jbenet","id":138401,"avatar_url":"https://avatars.githubusercontent.com/u/138401?v=3","gravatar_id":"","url":"https://api.github.com/users/jbenet","html_url":"https://github.com/jbenet","followers_url":"https://api.github.com/users/jbenet/followers","following_url":"https://api.github.com/users/jbenet/following{/other_user}","gists_url":"https://api.github.com/users/jbenet/gists{/gist_id}","starred_url":"https://api.github.com/users/jbenet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jbenet/subscriptions","organizations_url":"https://api.github.com/users/jbenet/orgs","repos_url":"https://api.github.com/users/jbenet/repos","events_url":"https://api.github.com/users/jbenet/events{/privacy}","received_events_url":"https://api.github.com/users/jbenet/received_events","type":"User","site_admin":false},"body":"We split #196 in two parts. this is the second. (#262 is the first). This builds on all the changes to commands/.","created_at":"2014-11-04T09:54:41Z","updated_at":"2014-11-09T11:50:06Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e5a2c220ecb0892f8b02340807ad7d25b8e79987","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/jbenet/go-ipfs/pulls/263/commits","review_comments_url":"https://api.github.com/repos/jbenet/go-ipfs/pulls/263/comments","review_comment_url":"https://api.github.com/repos/jbenet/go-ipfs/pulls/comments/{number}","comments_url":"https://api.github.com/repos/jbenet/go-ipfs/issues/263/comments","statuses_url":"https://api.github.com/repos/jbenet/go-ipfs/statuses/418ae0bd0f76c808055c76685bdeab94d5e59a72","head":{"label":"jbenet:cmd-ref-part2","ref":"cmd-ref-part2","sha":"418ae0bd0f76c808055c76685bdeab94d5e59a72","user":{"login":"jbenet","id":138401,"avatar_url":"https://avatars.githubusercontent.com/u/138401?v=3","gravatar_id":"","url":"https://api.github.com/users/jbenet","html_url":"https://github.com/jbenet","followers_url":"https://api.github.com/users/jbenet/followers","following_url":"https://api.github.com/users/jbenet/following{/other_user}","gists_url":"https://api.github.com/users/jbenet/gists{/gist_id}","starred_url":"https://api.github.com/users/jbenet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jbenet/subscriptions","organizations_url":"https://api.github.com/users/jbenet/orgs","repos_url":"https://api.github.com/users/jbenet/repos","events_url":"https://api.github.com/users/jbenet/events{/privacy}","received_events_url":"https://api.github.com/users/jbenet/received_events","type":"User","site_admin":false},"repo":{"id":21233191,"name":"go-ipfs","full_name":"jbenet/go-ipfs","owner":{"login":"jbenet","id":138401,"avatar_url":"https://avatars.githubusercontent.com/u/138401?v=3","gravatar_id":"","url":"https://api.github.com/users/jbenet","html_url":"https://github.com/jbenet","followers_url":"https://api.github.com/users/jbenet/followers","following_url":"https://api.github.com/users/jbenet/following{/other_user}","gists_url":"https://api.github.com/users/jbenet/gists{/gist_id}","starred_url":"https://api.github.com/users/jbenet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jbenet/subscriptions","organizations_url":"https://api.github.com/users/jbenet/orgs","repos_url":"https://api.github.com/users/jbenet/repos","events_url":"https://api.github.com/users/jbenet/events{/privacy}","received_events_url":"https://api.github.com/users/jbenet/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jbenet/go-ipfs","description":"ipfs implementation in go","fork":false,"url":"https://api.github.com/repos/jbenet/go-ipfs","forks_url":"https://api.github.com/repos/jbenet/go-ipfs/forks","keys_url":"https://api.github.com/repos/jbenet/go-ipfs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jbenet/go-ipfs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jbenet/go-ipfs/teams","hooks_url":"https://api.github.com/repos/jbenet/go-ipfs/hooks","issue_events_url":"https://api.github.com/repos/jbenet/go-ipfs/issues/events{/number}","events_url":"https://api.github.com/repos/jbenet/go-ipfs/events","assignees_url":"https://api.github.com/repos/jbenet/go-ipfs/assignees{/user}","branches_url":"https://api.github.com/repos/jbenet/go-ipfs/branches{/branch}","tags_url":"https://api.github.com/repos/jbenet/go-ipfs/tags","blobs_url":"https://api.github.com/repos/jbenet/go-ipfs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jbenet/go-ipfs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jbenet/go-ipfs/git/refs{/sha}","trees_url":"https://api.github.com/repos/jbenet/go-ipfs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jbenet/go-ipfs/statuses/{sha}","languages_url":"https://api.github.com/repos/jbenet/go-ipfs/languages","stargazers_url":"https://api.github.com/repos/jbenet/go-ipfs/stargazers","contributors_url":"https://api.github.com/repos/jbenet/go-ipfs/contributors","subscribers_url":"https://api.github.com/repos/jbenet/go-ipfs/subscribers","subscription_url":"https://api.github.com/repos/jbenet/go-ipfs/subscription","commits_url":"https://api.github.com/repos/jbenet/go-ipfs/commits{/sha}","git_commits_url":"https://api.github.com/repos/jbenet/go-ipfs/git/commits{/sha}","comments_url":"https://api.github.com/repos/jbenet/go-ipfs/comments{/number}","issue_comment_url":"https://api.github.com/repos/jbenet/go-ipfs/issues/comments/{number}","contents_url":"https://api.github.com/repos/jbenet/go-ipfs/contents/{+path}","compare_url":"https://api.github.com/repos/jbenet/go-ipfs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jbenet/go-ipfs/merges","archive_url":"https://api.github.com/repos/jbenet/go-ipfs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jbenet/go-ipfs/downloads","issues_url":"https://api.github.com/repos/jbenet/go-ipfs/issues{/number}","pulls_url":"https://api.github.com/repos/jbenet/go-ipfs/pulls{/number}","milestones_url":"https://api.github.com/repos/jbenet/go-ipfs/milestones{/number}","notifications_url":"https://api.github.com/repos/jbenet/go-ipfs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jbenet/go-ipfs/labels{/name}","releases_url":"https://api.github.com/repos/jbenet/go-ipfs/releases{/id}","created_at":"2014-06-26T08:14:34Z","updated_at":"2014-11-03T12:43:15Z","pushed_at":"2014-11-09T10:05:48Z","git_url":"git://github.com/jbenet/go-ipfs.git","ssh_url":"git@github.com:jbenet/go-ipfs.git","clone_url":"https://github.com/jbenet/go-ipfs.git","svn_url":"https://github.com/jbenet/go-ipfs","homepage":"https://github.com/jbenet/ipfs","size":10209,"stargazers_count":191,"watchers_count":191,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":30,"mirror_url":null,"open_issues_count":77,"forks":30,"open_issues":77,"watchers":191,"default_branch":"master"}},"base":{"label":"jbenet:master","ref":"master","sha":"265106143c025eed5e256bba5d3c90ae681ae653","user":{"login":"jbenet","id":138401,"avatar_url":"https://avatars.githubusercontent.com/u/138401?v=3","gravatar_id":"","url":"https://api.github.com/users/jbenet","html_url":"https://github.com/jbenet","followers_url":"https://api.github.com/users/jbenet/followers","following_url":"https://api.github.com/users/jbenet/following{/other_user}","gists_url":"https://api.github.com/users/jbenet/gists{/gist_id}","starred_url":"https://api.github.com/users/jbenet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jbenet/subscriptions","organizations_url":"https://api.github.com/users/jbenet/orgs","repos_url":"https://api.github.com/users/jbenet/repos","events_url":"https://api.github.com/users/jbenet/events{/privacy}","received_events_url":"https://api.github.com/users/jbenet/received_events","type":"User","site_admin":false},"repo":{"id":21233191,"name":"go-ipfs","full_name":"jbenet/go-ipfs","owner":{"login":"jbenet","id":138401,"avatar_url":"https://avatars.githubusercontent.com/u/138401?v=3","gravatar_id":"","url":"https://api.github.com/users/jbenet","html_url":"https://github.com/jbenet","followers_url":"https://api.github.com/users/jbenet/followers","following_url":"https://api.github.com/users/jbenet/following{/other_user}","gists_url":"https://api.github.com/users/jbenet/gists{/gist_id}","starred_url":"https://api.github.com/users/jbenet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jbenet/subscriptions","organizations_url":"https://api.github.com/users/jbenet/orgs","repos_url":"https://api.github.com/users/jbenet/repos","events_url":"https://api.github.com/users/jbenet/events{/privacy}","received_events_url":"https://api.github.com/users/jbenet/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jbenet/go-ipfs","description":"ipfs implementation in go","fork":false,"url":"https://api.github.com/repos/jbenet/go-ipfs","forks_url":"https://api.github.com/repos/jbenet/go-ipfs/forks","keys_url":"https://api.github.com/repos/jbenet/go-ipfs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jbenet/go-ipfs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jbenet/go-ipfs/teams","hooks_url":"https://api.github.com/repos/jbenet/go-ipfs/hooks","issue_events_url":"https://api.github.com/repos/jbenet/go-ipfs/issues/events{/number}","events_url":"https://api.github.com/repos/jbenet/go-ipfs/events","assignees_url":"https://api.github.com/repos/jbenet/go-ipfs/assignees{/user}","branches_url":"https://api.github.com/repos/jbenet/go-ipfs/branches{/branch}","tags_url":"https://api.github.com/repos/jbenet/go-ipfs/tags","blobs_url":"https://api.github.com/repos/jbenet/go-ipfs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jbenet/go-ipfs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jbenet/go-ipfs/git/refs{/sha}","trees_url":"https://api.github.com/repos/jbenet/go-ipfs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jbenet/go-ipfs/statuses/{sha}","languages_url":"https://api.github.com/repos/jbenet/go-ipfs/languages","stargazers_url":"https://api.github.com/repos/jbenet/go-ipfs/stargazers","contributors_url":"https://api.github.com/repos/jbenet/go-ipfs/contributors","subscribers_url":"https://api.github.com/repos/jbenet/go-ipfs/subscribers","subscription_url":"https://api.github.com/repos/jbenet/go-ipfs/subscription","commits_url":"https://api.github.com/repos/jbenet/go-ipfs/commits{/sha}","git_commits_url":"https://api.github.com/repos/jbenet/go-ipfs/git/commits{/sha}","comments_url":"https://api.github.com/repos/jbenet/go-ipfs/comments{/number}","issue_comment_url":"https://api.github.com/repos/jbenet/go-ipfs/issues/comments/{number}","contents_url":"https://api.github.com/repos/jbenet/go-ipfs/contents/{+path}","compare_url":"https://api.github.com/repos/jbenet/go-ipfs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jbenet/go-ipfs/merges","archive_url":"https://api.github.com/repos/jbenet/go-ipfs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jbenet/go-ipfs/downloads","issues_url":"https://api.github.com/repos/jbenet/go-ipfs/issues{/number}","pulls_url":"https://api.github.com/repos/jbenet/go-ipfs/pulls{/number}","milestones_url":"https://api.github.com/repos/jbenet/go-ipfs/milestones{/number}","notifications_url":"https://api.github.com/repos/jbenet/go-ipfs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jbenet/go-ipfs/labels{/name}","releases_url":"https://api.github.com/repos/jbenet/go-ipfs/releases{/id}","created_at":"2014-06-26T08:14:34Z","updated_at":"2014-11-03T12:43:15Z","pushed_at":"2014-11-09T10:05:48Z","git_url":"git://github.com/jbenet/go-ipfs.git","ssh_url":"git@github.com:jbenet/go-ipfs.git","clone_url":"https://github.com/jbenet/go-ipfs.git","svn_url":"https://github.com/jbenet/go-ipfs","homepage":"https://github.com/jbenet/ipfs","size":10209,"stargazers_count":191,"watchers_count":191,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":30,"mirror_url":null,"open_issues_count":77,"forks":30,"open_issues":77,"watchers":191,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/jbenet/go-ipfs/pulls/263"},"html":{"href":"https://github.com/jbenet/go-ipfs/pull/263"},"issue":{"href":"https://api.github.com/repos/jbenet/go-ipfs/issues/263"},"comments":{"href":"https://api.github.com/repos/jbenet/go-ipfs/issues/263/comments"},"review_comments":{"href":"https://api.github.com/repos/jbenet/go-ipfs/pulls/263/comments"},"review_comment":{"href":"https://api.github.com/repos/jbenet/go-ipfs/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/jbenet/go-ipfs/pulls/263/commits"},"statuses":{"href":"https://api.github.com/repos/jbenet/go-ipfs/statuses/418ae0bd0f76c808055c76685bdeab94d5e59a72"}}}}