{"action":"created","comment":{"url":"https://api.github.com/repos/awslabs/aws-sam-local/pulls/comments/145578780","pull_request_review_id":70398429,"id":145578780,"diff_hunk":"@@ -1,367 +1,158 @@\n package main\n \n import (\n-\t\"encoding/base64\"\n-\t\"fmt\"\n-\t\"os\"\n-\t\"text/template\"\n-\n+\t\"log\"\n \t\"github.com/codegangsta/cli\"\n+\t\"strings\"\n+\t\"fmt\"\n+\t\"encoding/json\"\n+\t\"regexp\"\n )\n \n-var events = map[string]string{\n-\t\"S3\":       s3Event,\n-\t\"SNS\":      snsEvent,\n-\t\"Kinesis\":  kinesisEvent,\n-\t\"DynamoDB\": dynamodbEvent,\n-\t\"Api\":      apiEvent,\n-\t\"Schedule\": scheduleEvent,\n+/**\n+    The go:generate tag is used to generate a binary go file that\n+    contains all data from the sample-events folder, which is used\n+    by this file to generate commands for generate-event. If any changes\n+    are made to the sample-events folder, the binary file will need to be\n+    re-generated via running\n+        'go generate'\n+    in the project root folder. This command requires go-bindata, which can be\n+    installed by running\n+        'go get -u github.com/jteeuwen/go-bindata/...'\n+ */\n+// ***DO NOT EDIT THE FOLLOWING COMMENT - it is required for 'go generate' to work***\n+//go:generate go-bindata -o generated-event-binary.go sample-events/...\n+\n+var nameToCommandMap map[string]string = make(map[string]string)\n+var nameToDescriptionMap map[string]string = make(map[string]string)\n+var nameToFlagListMap map[string][]Flag = make(map[string][]Flag)\n+\n+type CommandMap struct {\n+\tCommands []Command\n }\n \n-func generate(eventType string, c *cli.Context) {\n+type Command struct {\n+\tName        string `json:\"name\"`\n+\tCommand     string `json:\"command\"`\n+\tDescription string `json:\"description\"`\n+\tFlags       []Flag `json:\"flags\"`\n+}\n \n-\tsample, ok := events[eventType]\n-\tif !ok {\n-\t\tfmt.Printf(\"Unsupported event type: %s\", eventType)\n-\t\tos.Exit(1)\n-\t}\n+type Flag struct {\n+\tName    string `json:\"name\"`\n+\tUsage   string `json:\"usage\"`\n+\tValue   string `json:\"value\"`\n+}\n \n-\tt, err := template.New(\"event\").Parse(sample)\n+// Generates top-level commands for generate-event for all\n+// categories under sample-events\n+func generateEventCategories() (categories []cli.Command) {\n+\tmapFileToCommands()\n+\n+\tdirs, err := AssetDir(\"sample-events\")\n \tif err != nil {\n-\t\tfmt.Printf(\"Failed to load sample %s event: %s\", eventType, err)\n-\t\tos.Exit(1)\n+\t\tlog.Fatal(err)\n+\t}\n+\n+\tfor _, dir := range dirs {\n+\t\tif (strings.Contains(dir, \".\")) {\n+\t\t\t// Skip names that are not directories\n+\t\t\tcontinue\n+\t\t}\n+\t\tcommand := cli.Command{\n+\t\t\tName:  strings.Replace(strings.ToLower(dir), \" \", \"-\", -1),\n+\t\t\tUsage: \"View available events for \" + dir + \"\",\n+\t\t\tSubcommands: generateCategorySubCommands(dir),\n+\t\t}\n+\n+\t\tcategories = append(categories, command)\n \t}\n \n-\tswitch eventType {\n-\tcase \"S3\":\n+\treturn\n+}\n+\n+func generateCategorySubCommands(subDir string) (subcommands []cli.Command){\n+\tpath := \"sample-events/\" + subDir\n+\tfiles, err := AssetDir(path)","path":"generate-event.go","position":99,"original_position":99,"commit_id":"799da1e012f5727fa61cb8fc10a23c9d7fdd233e","original_commit_id":"799da1e012f5727fa61cb8fc10a23c9d7fdd233e","user":{"login":"sanathkr","id":22755571,"avatar_url":"https://avatars3.githubusercontent.com/u/22755571?v=4","gravatar_id":"","url":"https://api.github.com/users/sanathkr","html_url":"https://github.com/sanathkr","followers_url":"https://api.github.com/users/sanathkr/followers","following_url":"https://api.github.com/users/sanathkr/following{/other_user}","gists_url":"https://api.github.com/users/sanathkr/gists{/gist_id}","starred_url":"https://api.github.com/users/sanathkr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sanathkr/subscriptions","organizations_url":"https://api.github.com/users/sanathkr/orgs","repos_url":"https://api.github.com/users/sanathkr/repos","events_url":"https://api.github.com/users/sanathkr/events{/privacy}","received_events_url":"https://api.github.com/users/sanathkr/received_events","type":"User","site_admin":false},"body":"`AssetDir` is a method from go-bindata right? You don't seem to include it here why?","created_at":"2017-10-19T00:50:34Z","updated_at":"2017-10-19T00:56:03Z","html_url":"https://github.com/awslabs/aws-sam-local/pull/133#discussion_r145578780","pull_request_url":"https://api.github.com/repos/awslabs/aws-sam-local/pulls/133","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/awslabs/aws-sam-local/pulls/comments/145578780"},"html":{"href":"https://github.com/awslabs/aws-sam-local/pull/133#discussion_r145578780"},"pull_request":{"href":"https://api.github.com/repos/awslabs/aws-sam-local/pulls/133"}}},"pull_request":{"url":"https://api.github.com/repos/awslabs/aws-sam-local/pulls/133","id":142438250,"html_url":"https://github.com/awslabs/aws-sam-local/pull/133","diff_url":"https://github.com/awslabs/aws-sam-local/pull/133.diff","patch_url":"https://github.com/awslabs/aws-sam-local/pull/133.patch","issue_url":"https://api.github.com/repos/awslabs/aws-sam-local/issues/133","number":133,"state":"open","locked":false,"title":"Added additional event sources for generate-event","user":{"login":"stshan","id":9020405,"avatar_url":"https://avatars3.githubusercontent.com/u/9020405?v=4","gravatar_id":"","url":"https://api.github.com/users/stshan","html_url":"https://github.com/stshan","followers_url":"https://api.github.com/users/stshan/followers","following_url":"https://api.github.com/users/stshan/following{/other_user}","gists_url":"https://api.github.com/users/stshan/gists{/gist_id}","starred_url":"https://api.github.com/users/stshan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stshan/subscriptions","organizations_url":"https://api.github.com/users/stshan/orgs","repos_url":"https://api.github.com/users/stshan/repos","events_url":"https://api.github.com/users/stshan/events{/privacy}","received_events_url":"https://api.github.com/users/stshan/received_events","type":"User","site_admin":false},"body":"Added some additional event sources and event samples for generate-event","created_at":"2017-09-21T20:30:23Z","updated_at":"2017-10-19T00:56:03Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b6940c5d69960539efa02b7df6ad2b74d839dcc8","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/awslabs/aws-sam-local/pulls/133/commits","review_comments_url":"https://api.github.com/repos/awslabs/aws-sam-local/pulls/133/comments","review_comment_url":"https://api.github.com/repos/awslabs/aws-sam-local/pulls/comments{/number}","comments_url":"https://api.github.com/repos/awslabs/aws-sam-local/issues/133/comments","statuses_url":"https://api.github.com/repos/awslabs/aws-sam-local/statuses/799da1e012f5727fa61cb8fc10a23c9d7fdd233e","head":{"label":"stshan:develop","ref":"develop","sha":"799da1e012f5727fa61cb8fc10a23c9d7fdd233e","user":{"login":"stshan","id":9020405,"avatar_url":"https://avatars3.githubusercontent.com/u/9020405?v=4","gravatar_id":"","url":"https://api.github.com/users/stshan","html_url":"https://github.com/stshan","followers_url":"https://api.github.com/users/stshan/followers","following_url":"https://api.github.com/users/stshan/following{/other_user}","gists_url":"https://api.github.com/users/stshan/gists{/gist_id}","starred_url":"https://api.github.com/users/stshan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stshan/subscriptions","organizations_url":"https://api.github.com/users/stshan/orgs","repos_url":"https://api.github.com/users/stshan/repos","events_url":"https://api.github.com/users/stshan/events{/privacy}","received_events_url":"https://api.github.com/users/stshan/received_events","type":"User","site_admin":false},"repo":{"id":104254673,"name":"aws-sam-local","full_name":"stshan/aws-sam-local","owner":{"login":"stshan","id":9020405,"avatar_url":"https://avatars3.githubusercontent.com/u/9020405?v=4","gravatar_id":"","url":"https://api.github.com/users/stshan","html_url":"https://github.com/stshan","followers_url":"https://api.github.com/users/stshan/followers","following_url":"https://api.github.com/users/stshan/following{/other_user}","gists_url":"https://api.github.com/users/stshan/gists{/gist_id}","starred_url":"https://api.github.com/users/stshan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stshan/subscriptions","organizations_url":"https://api.github.com/users/stshan/orgs","repos_url":"https://api.github.com/users/stshan/repos","events_url":"https://api.github.com/users/stshan/events{/privacy}","received_events_url":"https://api.github.com/users/stshan/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/stshan/aws-sam-local","description":"AWS SAM Local 🐿 is a CLI tool for local development and testing of Serverless applications","fork":true,"url":"https://api.github.com/repos/stshan/aws-sam-local","forks_url":"https://api.github.com/repos/stshan/aws-sam-local/forks","keys_url":"https://api.github.com/repos/stshan/aws-sam-local/keys{/key_id}","collaborators_url":"https://api.github.com/repos/stshan/aws-sam-local/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/stshan/aws-sam-local/teams","hooks_url":"https://api.github.com/repos/stshan/aws-sam-local/hooks","issue_events_url":"https://api.github.com/repos/stshan/aws-sam-local/issues/events{/number}","events_url":"https://api.github.com/repos/stshan/aws-sam-local/events","assignees_url":"https://api.github.com/repos/stshan/aws-sam-local/assignees{/user}","branches_url":"https://api.github.com/repos/stshan/aws-sam-local/branches{/branch}","tags_url":"https://api.github.com/repos/stshan/aws-sam-local/tags","blobs_url":"https://api.github.com/repos/stshan/aws-sam-local/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/stshan/aws-sam-local/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/stshan/aws-sam-local/git/refs{/sha}","trees_url":"https://api.github.com/repos/stshan/aws-sam-local/git/trees{/sha}","statuses_url":"https://api.github.com/repos/stshan/aws-sam-local/statuses/{sha}","languages_url":"https://api.github.com/repos/stshan/aws-sam-local/languages","stargazers_url":"https://api.github.com/repos/stshan/aws-sam-local/stargazers","contributors_url":"https://api.github.com/repos/stshan/aws-sam-local/contributors","subscribers_url":"https://api.github.com/repos/stshan/aws-sam-local/subscribers","subscription_url":"https://api.github.com/repos/stshan/aws-sam-local/subscription","commits_url":"https://api.github.com/repos/stshan/aws-sam-local/commits{/sha}","git_commits_url":"https://api.github.com/repos/stshan/aws-sam-local/git/commits{/sha}","comments_url":"https://api.github.com/repos/stshan/aws-sam-local/comments{/number}","issue_comment_url":"https://api.github.com/repos/stshan/aws-sam-local/issues/comments{/number}","contents_url":"https://api.github.com/repos/stshan/aws-sam-local/contents/{+path}","compare_url":"https://api.github.com/repos/stshan/aws-sam-local/compare/{base}...{head}","merges_url":"https://api.github.com/repos/stshan/aws-sam-local/merges","archive_url":"https://api.github.com/repos/stshan/aws-sam-local/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/stshan/aws-sam-local/downloads","issues_url":"https://api.github.com/repos/stshan/aws-sam-local/issues{/number}","pulls_url":"https://api.github.com/repos/stshan/aws-sam-local/pulls{/number}","milestones_url":"https://api.github.com/repos/stshan/aws-sam-local/milestones{/number}","notifications_url":"https://api.github.com/repos/stshan/aws-sam-local/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/stshan/aws-sam-local/labels{/name}","releases_url":"https://api.github.com/repos/stshan/aws-sam-local/releases{/id}","deployments_url":"https://api.github.com/repos/stshan/aws-sam-local/deployments","created_at":"2017-09-20T18:44:03Z","updated_at":"2017-09-20T18:44:05Z","pushed_at":"2017-10-03T00:16:28Z","git_url":"git://github.com/stshan/aws-sam-local.git","ssh_url":"git@github.com:stshan/aws-sam-local.git","clone_url":"https://github.com/stshan/aws-sam-local.git","svn_url":"https://github.com/stshan/aws-sam-local","homepage":"","size":13404,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"develop"}},"base":{"label":"awslabs:develop","ref":"develop","sha":"63a2bc7d21d9ded01d133f859d46c38729955b3f","user":{"login":"awslabs","id":3299148,"avatar_url":"https://avatars0.githubusercontent.com/u/3299148?v=4","gravatar_id":"","url":"https://api.github.com/users/awslabs","html_url":"https://github.com/awslabs","followers_url":"https://api.github.com/users/awslabs/followers","following_url":"https://api.github.com/users/awslabs/following{/other_user}","gists_url":"https://api.github.com/users/awslabs/gists{/gist_id}","starred_url":"https://api.github.com/users/awslabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/awslabs/subscriptions","organizations_url":"https://api.github.com/users/awslabs/orgs","repos_url":"https://api.github.com/users/awslabs/repos","events_url":"https://api.github.com/users/awslabs/events{/privacy}","received_events_url":"https://api.github.com/users/awslabs/received_events","type":"Organization","site_admin":false},"repo":{"id":92205085,"name":"aws-sam-local","full_name":"awslabs/aws-sam-local","owner":{"login":"awslabs","id":3299148,"avatar_url":"https://avatars0.githubusercontent.com/u/3299148?v=4","gravatar_id":"","url":"https://api.github.com/users/awslabs","html_url":"https://github.com/awslabs","followers_url":"https://api.github.com/users/awslabs/followers","following_url":"https://api.github.com/users/awslabs/following{/other_user}","gists_url":"https://api.github.com/users/awslabs/gists{/gist_id}","starred_url":"https://api.github.com/users/awslabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/awslabs/subscriptions","organizations_url":"https://api.github.com/users/awslabs/orgs","repos_url":"https://api.github.com/users/awslabs/repos","events_url":"https://api.github.com/users/awslabs/events{/privacy}","received_events_url":"https://api.github.com/users/awslabs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/awslabs/aws-sam-local","description":"AWS SAM Local 🐿 is a CLI tool for local development and testing of Serverless applications","fork":false,"url":"https://api.github.com/repos/awslabs/aws-sam-local","forks_url":"https://api.github.com/repos/awslabs/aws-sam-local/forks","keys_url":"https://api.github.com/repos/awslabs/aws-sam-local/keys{/key_id}","collaborators_url":"https://api.github.com/repos/awslabs/aws-sam-local/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/awslabs/aws-sam-local/teams","hooks_url":"https://api.github.com/repos/awslabs/aws-sam-local/hooks","issue_events_url":"https://api.github.com/repos/awslabs/aws-sam-local/issues/events{/number}","events_url":"https://api.github.com/repos/awslabs/aws-sam-local/events","assignees_url":"https://api.github.com/repos/awslabs/aws-sam-local/assignees{/user}","branches_url":"https://api.github.com/repos/awslabs/aws-sam-local/branches{/branch}","tags_url":"https://api.github.com/repos/awslabs/aws-sam-local/tags","blobs_url":"https://api.github.com/repos/awslabs/aws-sam-local/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/awslabs/aws-sam-local/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/awslabs/aws-sam-local/git/refs{/sha}","trees_url":"https://api.github.com/repos/awslabs/aws-sam-local/git/trees{/sha}","statuses_url":"https://api.github.com/repos/awslabs/aws-sam-local/statuses/{sha}","languages_url":"https://api.github.com/repos/awslabs/aws-sam-local/languages","stargazers_url":"https://api.github.com/repos/awslabs/aws-sam-local/stargazers","contributors_url":"https://api.github.com/repos/awslabs/aws-sam-local/contributors","subscribers_url":"https://api.github.com/repos/awslabs/aws-sam-local/subscribers","subscription_url":"https://api.github.com/repos/awslabs/aws-sam-local/subscription","commits_url":"https://api.github.com/repos/awslabs/aws-sam-local/commits{/sha}","git_commits_url":"https://api.github.com/repos/awslabs/aws-sam-local/git/commits{/sha}","comments_url":"https://api.github.com/repos/awslabs/aws-sam-local/comments{/number}","issue_comment_url":"https://api.github.com/repos/awslabs/aws-sam-local/issues/comments{/number}","contents_url":"https://api.github.com/repos/awslabs/aws-sam-local/contents/{+path}","compare_url":"https://api.github.com/repos/awslabs/aws-sam-local/compare/{base}...{head}","merges_url":"https://api.github.com/repos/awslabs/aws-sam-local/merges","archive_url":"https://api.github.com/repos/awslabs/aws-sam-local/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/awslabs/aws-sam-local/downloads","issues_url":"https://api.github.com/repos/awslabs/aws-sam-local/issues{/number}","pulls_url":"https://api.github.com/repos/awslabs/aws-sam-local/pulls{/number}","milestones_url":"https://api.github.com/repos/awslabs/aws-sam-local/milestones{/number}","notifications_url":"https://api.github.com/repos/awslabs/aws-sam-local/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/awslabs/aws-sam-local/labels{/name}","releases_url":"https://api.github.com/repos/awslabs/aws-sam-local/releases{/id}","deployments_url":"https://api.github.com/repos/awslabs/aws-sam-local/deployments","created_at":"2017-05-23T18:16:23Z","updated_at":"2017-10-18T22:08:23Z","pushed_at":"2017-10-13T14:04:25Z","git_url":"git://github.com/awslabs/aws-sam-local.git","ssh_url":"git@github.com:awslabs/aws-sam-local.git","clone_url":"https://github.com/awslabs/aws-sam-local.git","svn_url":"https://github.com/awslabs/aws-sam-local","homepage":"","size":13368,"stargazers_count":966,"watchers_count":966,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":84,"mirror_url":null,"open_issues_count":38,"forks":84,"open_issues":38,"watchers":966,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/awslabs/aws-sam-local/pulls/133"},"html":{"href":"https://github.com/awslabs/aws-sam-local/pull/133"},"issue":{"href":"https://api.github.com/repos/awslabs/aws-sam-local/issues/133"},"comments":{"href":"https://api.github.com/repos/awslabs/aws-sam-local/issues/133/comments"},"review_comments":{"href":"https://api.github.com/repos/awslabs/aws-sam-local/pulls/133/comments"},"review_comment":{"href":"https://api.github.com/repos/awslabs/aws-sam-local/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/awslabs/aws-sam-local/pulls/133/commits"},"statuses":{"href":"https://api.github.com/repos/awslabs/aws-sam-local/statuses/799da1e012f5727fa61cb8fc10a23c9d7fdd233e"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"sanathkr"}}