{"action":"created","comment":{"url":"https://api.github.com/repos/apache/incubator-openwhisk/pulls/comments/144978426","pull_request_review_id":69711119,"id":144978426,"diff_hunk":"@@ -811,6 +813,81 @@ class WskBasicUsageTests extends TestHelpers with WskTestHelpers {\n     stdoutNoDescOrParams should include regex (s\"(?i)action /${namespace}/${actNameNoDescOrParams}\\\\s*\\\\(parameters: none defined\\\\)\")\n   }\n \n+  it should \"save action code to file\" in withAssetCleaner(wskprops) { (wp, assetHelper) =>\n+    val name = \"saveAction\"\n+    val seqName = \"seqName\"\n+    val dockerName = \"dockerName\"\n+    val containerName = s\"bogus${Random.alphanumeric.take(16).mkString.toLowerCase}\"\n+    val saveName = s\"save-as-$name.js\"\n+    val badSaveName = s\"bad-directory${File.separator}$saveName\"\n+\n+    // Test for successful --save\n+    assetHelper.withCleaner(wsk.action, name) { (action, _) =>\n+      action.create(name, defaultAction)\n+    }\n+\n+    val saveMsg = wsk.action.get(name, save = Some(true)).stdout\n+\n+    saveMsg should include(s\"saved action code to \")\n+\n+    val savePath = saveMsg.split(\"ok: saved action code to \")(1).trim()\n+    val saveFile = new File(savePath);\n+\n+    try {\n+      saveFile.exists shouldBe true\n+\n+      // Test for failure saving file when it already exist\n+      wsk.action.get(name, save = Some(true), expectedExitCode = MISUSE_EXIT).stderr should include(\n+        s\"The file '$name.js' already exists\")\n+    } finally {\n+      saveFile.delete()\n+    }\n+\n+    // Test for successful --save-as\n+    val saveAsMsg = wsk.action.get(name, saveAs = Some(saveName)).stdout\n+\n+    saveAsMsg should include(s\"saved action code to \")\n+\n+    val saveAsPath = saveAsMsg.split(\"ok: saved action code to \")(1).trim()\n+    val saveAsFile = new File(saveAsPath);\n+\n+    try {\n+      saveAsFile.exists shouldBe true\n+\n+      // Test for failure saving file when it already exist\n+      wsk.action.get(name, saveAs = Some(saveName), expectedExitCode = MISUSE_EXIT).stderr should include(\n+        s\"The file '$saveName' already exists\")\n+    } finally {\n+      saveAsFile.delete()\n+    }\n+\n+    // Test for failure when using an invalid filename\n+    wsk.action.get(name, saveAs = Some(badSaveName), expectedExitCode = MISUSE_EXIT).stderr should include(\n+      s\"Cannot create file '$badSaveName'\")\n+\n+    // Test for failure saving Docker images\n+    assetHelper.withCleaner(wsk.action, dockerName) { (action, _) =>\n+      action.create(dockerName, None, docker = Some(containerName))\n+    }\n+\n+    wsk.action.get(dockerName, save = Some(true), expectedExitCode = MISUSE_EXIT).stderr should include(\n+      \"Cannot save Docker images\")\n+\n+    wsk.action.get(dockerName, saveAs = Some(dockerName), expectedExitCode = MISUSE_EXIT).stderr should include(\n+      \"Cannot save Docker images\")\n+\n+    // Tes for failure saving sequences\n+    assetHelper.withCleaner(wsk.action, seqName) { (action, _) =>\n+      action.create(seqName, Some(name), kind = Some(\"sequence\"))\n+    }\n+\n+    wsk.action.get(seqName, save = Some(true), expectedExitCode = MISUSE_EXIT).stderr should include(\n+      \"Cannot save action sequence\")","path":"tests/src/test/scala/whisk/core/cli/test/WskBasicUsageTests.scala","position":93,"original_position":93,"commit_id":"10ebfa19e121d4ce6393245e6b2fa25a15e914ad","original_commit_id":"10ebfa19e121d4ce6393245e6b2fa25a15e914ad","user":{"login":"dubeejw","id":11520887,"avatar_url":"https://avatars3.githubusercontent.com/u/11520887?v=4","gravatar_id":"","url":"https://api.github.com/users/dubeejw","html_url":"https://github.com/dubeejw","followers_url":"https://api.github.com/users/dubeejw/followers","following_url":"https://api.github.com/users/dubeejw/following{/other_user}","gists_url":"https://api.github.com/users/dubeejw/gists{/gist_id}","starred_url":"https://api.github.com/users/dubeejw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dubeejw/subscriptions","organizations_url":"https://api.github.com/users/dubeejw/orgs","repos_url":"https://api.github.com/users/dubeejw/repos","events_url":"https://api.github.com/users/dubeejw/events{/privacy}","received_events_url":"https://api.github.com/users/dubeejw/received_events","type":"User","site_admin":false},"body":"Yes.\r\n","created_at":"2017-10-16T21:49:59Z","updated_at":"2017-10-16T21:49:59Z","html_url":"https://github.com/apache/incubator-openwhisk/pull/2544#discussion_r144978426","pull_request_url":"https://api.github.com/repos/apache/incubator-openwhisk/pulls/2544","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/apache/incubator-openwhisk/pulls/comments/144978426"},"html":{"href":"https://github.com/apache/incubator-openwhisk/pull/2544#discussion_r144978426"},"pull_request":{"href":"https://api.github.com/repos/apache/incubator-openwhisk/pulls/2544"}},"in_reply_to_id":144948805},"pull_request":{"url":"https://api.github.com/repos/apache/incubator-openwhisk/pulls/2544","id":133035024,"html_url":"https://github.com/apache/incubator-openwhisk/pull/2544","diff_url":"https://github.com/apache/incubator-openwhisk/pull/2544.diff","patch_url":"https://github.com/apache/incubator-openwhisk/pull/2544.patch","issue_url":"https://api.github.com/repos/apache/incubator-openwhisk/issues/2544","number":2544,"state":"open","locked":false,"title":"Allow CLI to Save Code from Action","user":{"login":"dubeejw","id":11520887,"avatar_url":"https://avatars3.githubusercontent.com/u/11520887?v=4","gravatar_id":"","url":"https://api.github.com/users/dubeejw","html_url":"https://github.com/dubeejw","followers_url":"https://api.github.com/users/dubeejw/followers","following_url":"https://api.github.com/users/dubeejw/following{/other_user}","gists_url":"https://api.github.com/users/dubeejw/gists{/gist_id}","starred_url":"https://api.github.com/users/dubeejw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dubeejw/subscriptions","organizations_url":"https://api.github.com/users/dubeejw/orgs","repos_url":"https://api.github.com/users/dubeejw/repos","events_url":"https://api.github.com/users/dubeejw/events{/privacy}","received_events_url":"https://api.github.com/users/dubeejw/received_events","type":"User","site_admin":false},"body":"- Prototype that allows the CLI to extract the code from an action and save that code on the local system\r\n\r\nUsage:\r\n`wsk action get ACTION_NAME --save`\r\n`wsk action get ACTION_NAME --save-as FILE_NAME`\r\n\r\n","created_at":"2017-07-28T19:19:21Z","updated_at":"2017-10-16T21:49:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c28c96d0c492341283d411828192a843c6b4cc03","assignee":{"login":"csantanapr","id":1094878,"avatar_url":"https://avatars0.githubusercontent.com/u/1094878?v=4","gravatar_id":"","url":"https://api.github.com/users/csantanapr","html_url":"https://github.com/csantanapr","followers_url":"https://api.github.com/users/csantanapr/followers","following_url":"https://api.github.com/users/csantanapr/following{/other_user}","gists_url":"https://api.github.com/users/csantanapr/gists{/gist_id}","starred_url":"https://api.github.com/users/csantanapr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/csantanapr/subscriptions","organizations_url":"https://api.github.com/users/csantanapr/orgs","repos_url":"https://api.github.com/users/csantanapr/repos","events_url":"https://api.github.com/users/csantanapr/events{/privacy}","received_events_url":"https://api.github.com/users/csantanapr/received_events","type":"User","site_admin":false},"assignees":[{"login":"csantanapr","id":1094878,"avatar_url":"https://avatars0.githubusercontent.com/u/1094878?v=4","gravatar_id":"","url":"https://api.github.com/users/csantanapr","html_url":"https://github.com/csantanapr","followers_url":"https://api.github.com/users/csantanapr/followers","following_url":"https://api.github.com/users/csantanapr/following{/other_user}","gists_url":"https://api.github.com/users/csantanapr/gists{/gist_id}","starred_url":"https://api.github.com/users/csantanapr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/csantanapr/subscriptions","organizations_url":"https://api.github.com/users/csantanapr/orgs","repos_url":"https://api.github.com/users/csantanapr/repos","events_url":"https://api.github.com/users/csantanapr/events{/privacy}","received_events_url":"https://api.github.com/users/csantanapr/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/apache/incubator-openwhisk/pulls/2544/commits","review_comments_url":"https://api.github.com/repos/apache/incubator-openwhisk/pulls/2544/comments","review_comment_url":"https://api.github.com/repos/apache/incubator-openwhisk/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/incubator-openwhisk/issues/2544/comments","statuses_url":"https://api.github.com/repos/apache/incubator-openwhisk/statuses/10ebfa19e121d4ce6393245e6b2fa25a15e914ad","head":{"label":"dubeejw:code-save","ref":"code-save","sha":"10ebfa19e121d4ce6393245e6b2fa25a15e914ad","user":{"login":"dubeejw","id":11520887,"avatar_url":"https://avatars3.githubusercontent.com/u/11520887?v=4","gravatar_id":"","url":"https://api.github.com/users/dubeejw","html_url":"https://github.com/dubeejw","followers_url":"https://api.github.com/users/dubeejw/followers","following_url":"https://api.github.com/users/dubeejw/following{/other_user}","gists_url":"https://api.github.com/users/dubeejw/gists{/gist_id}","starred_url":"https://api.github.com/users/dubeejw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dubeejw/subscriptions","organizations_url":"https://api.github.com/users/dubeejw/orgs","repos_url":"https://api.github.com/users/dubeejw/repos","events_url":"https://api.github.com/users/dubeejw/events{/privacy}","received_events_url":"https://api.github.com/users/dubeejw/received_events","type":"User","site_admin":false},"repo":{"id":56244037,"name":"openwhisk","full_name":"dubeejw/openwhisk","owner":{"login":"dubeejw","id":11520887,"avatar_url":"https://avatars3.githubusercontent.com/u/11520887?v=4","gravatar_id":"","url":"https://api.github.com/users/dubeejw","html_url":"https://github.com/dubeejw","followers_url":"https://api.github.com/users/dubeejw/followers","following_url":"https://api.github.com/users/dubeejw/following{/other_user}","gists_url":"https://api.github.com/users/dubeejw/gists{/gist_id}","starred_url":"https://api.github.com/users/dubeejw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dubeejw/subscriptions","organizations_url":"https://api.github.com/users/dubeejw/orgs","repos_url":"https://api.github.com/users/dubeejw/repos","events_url":"https://api.github.com/users/dubeejw/events{/privacy}","received_events_url":"https://api.github.com/users/dubeejw/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dubeejw/openwhisk","description":"OpenWhisk is a cloud-first distributed event-based programming service.","fork":true,"url":"https://api.github.com/repos/dubeejw/openwhisk","forks_url":"https://api.github.com/repos/dubeejw/openwhisk/forks","keys_url":"https://api.github.com/repos/dubeejw/openwhisk/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dubeejw/openwhisk/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dubeejw/openwhisk/teams","hooks_url":"https://api.github.com/repos/dubeejw/openwhisk/hooks","issue_events_url":"https://api.github.com/repos/dubeejw/openwhisk/issues/events{/number}","events_url":"https://api.github.com/repos/dubeejw/openwhisk/events","assignees_url":"https://api.github.com/repos/dubeejw/openwhisk/assignees{/user}","branches_url":"https://api.github.com/repos/dubeejw/openwhisk/branches{/branch}","tags_url":"https://api.github.com/repos/dubeejw/openwhisk/tags","blobs_url":"https://api.github.com/repos/dubeejw/openwhisk/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dubeejw/openwhisk/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dubeejw/openwhisk/git/refs{/sha}","trees_url":"https://api.github.com/repos/dubeejw/openwhisk/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dubeejw/openwhisk/statuses/{sha}","languages_url":"https://api.github.com/repos/dubeejw/openwhisk/languages","stargazers_url":"https://api.github.com/repos/dubeejw/openwhisk/stargazers","contributors_url":"https://api.github.com/repos/dubeejw/openwhisk/contributors","subscribers_url":"https://api.github.com/repos/dubeejw/openwhisk/subscribers","subscription_url":"https://api.github.com/repos/dubeejw/openwhisk/subscription","commits_url":"https://api.github.com/repos/dubeejw/openwhisk/commits{/sha}","git_commits_url":"https://api.github.com/repos/dubeejw/openwhisk/git/commits{/sha}","comments_url":"https://api.github.com/repos/dubeejw/openwhisk/comments{/number}","issue_comment_url":"https://api.github.com/repos/dubeejw/openwhisk/issues/comments{/number}","contents_url":"https://api.github.com/repos/dubeejw/openwhisk/contents/{+path}","compare_url":"https://api.github.com/repos/dubeejw/openwhisk/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dubeejw/openwhisk/merges","archive_url":"https://api.github.com/repos/dubeejw/openwhisk/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dubeejw/openwhisk/downloads","issues_url":"https://api.github.com/repos/dubeejw/openwhisk/issues{/number}","pulls_url":"https://api.github.com/repos/dubeejw/openwhisk/pulls{/number}","milestones_url":"https://api.github.com/repos/dubeejw/openwhisk/milestones{/number}","notifications_url":"https://api.github.com/repos/dubeejw/openwhisk/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dubeejw/openwhisk/labels{/name}","releases_url":"https://api.github.com/repos/dubeejw/openwhisk/releases{/id}","deployments_url":"https://api.github.com/repos/dubeejw/openwhisk/deployments","created_at":"2016-04-14T14:26:32Z","updated_at":"2016-04-14T14:26:34Z","pushed_at":"2017-10-16T21:22:42Z","git_url":"git://github.com/dubeejw/openwhisk.git","ssh_url":"git@github.com:dubeejw/openwhisk.git","clone_url":"https://github.com/dubeejw/openwhisk.git","svn_url":"https://github.com/dubeejw/openwhisk","homepage":"","size":57919,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"apache:master","ref":"master","sha":"1e27a81195c646239ab025c90d08684b2f7c7d74","user":{"login":"apache","id":47359,"avatar_url":"https://avatars0.githubusercontent.com/u/47359?v=4","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"repo":{"id":52039373,"name":"incubator-openwhisk","full_name":"apache/incubator-openwhisk","owner":{"login":"apache","id":47359,"avatar_url":"https://avatars0.githubusercontent.com/u/47359?v=4","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apache/incubator-openwhisk","description":"Apache OpenWhisk is a serverless event-based programming service and an Apache Incubator project.","fork":false,"url":"https://api.github.com/repos/apache/incubator-openwhisk","forks_url":"https://api.github.com/repos/apache/incubator-openwhisk/forks","keys_url":"https://api.github.com/repos/apache/incubator-openwhisk/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/incubator-openwhisk/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/incubator-openwhisk/teams","hooks_url":"https://api.github.com/repos/apache/incubator-openwhisk/hooks","issue_events_url":"https://api.github.com/repos/apache/incubator-openwhisk/issues/events{/number}","events_url":"https://api.github.com/repos/apache/incubator-openwhisk/events","assignees_url":"https://api.github.com/repos/apache/incubator-openwhisk/assignees{/user}","branches_url":"https://api.github.com/repos/apache/incubator-openwhisk/branches{/branch}","tags_url":"https://api.github.com/repos/apache/incubator-openwhisk/tags","blobs_url":"https://api.github.com/repos/apache/incubator-openwhisk/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/incubator-openwhisk/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/incubator-openwhisk/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/incubator-openwhisk/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/incubator-openwhisk/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/incubator-openwhisk/languages","stargazers_url":"https://api.github.com/repos/apache/incubator-openwhisk/stargazers","contributors_url":"https://api.github.com/repos/apache/incubator-openwhisk/contributors","subscribers_url":"https://api.github.com/repos/apache/incubator-openwhisk/subscribers","subscription_url":"https://api.github.com/repos/apache/incubator-openwhisk/subscription","commits_url":"https://api.github.com/repos/apache/incubator-openwhisk/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/incubator-openwhisk/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/incubator-openwhisk/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/incubator-openwhisk/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/incubator-openwhisk/contents/{+path}","compare_url":"https://api.github.com/repos/apache/incubator-openwhisk/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/incubator-openwhisk/merges","archive_url":"https://api.github.com/repos/apache/incubator-openwhisk/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/incubator-openwhisk/downloads","issues_url":"https://api.github.com/repos/apache/incubator-openwhisk/issues{/number}","pulls_url":"https://api.github.com/repos/apache/incubator-openwhisk/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/incubator-openwhisk/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/incubator-openwhisk/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/incubator-openwhisk/labels{/name}","releases_url":"https://api.github.com/repos/apache/incubator-openwhisk/releases{/id}","deployments_url":"https://api.github.com/repos/apache/incubator-openwhisk/deployments","created_at":"2016-02-18T21:16:19Z","updated_at":"2017-10-16T18:56:51Z","pushed_at":"2017-10-16T21:22:43Z","git_url":"git://github.com/apache/incubator-openwhisk.git","ssh_url":"git@github.com:apache/incubator-openwhisk.git","clone_url":"https://github.com/apache/incubator-openwhisk.git","svn_url":"https://github.com/apache/incubator-openwhisk","homepage":"http://openwhisk.org","size":57035,"stargazers_count":2025,"watchers_count":2025,"language":"Scala","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":439,"mirror_url":null,"open_issues_count":413,"forks":439,"open_issues":413,"watchers":2025,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/incubator-openwhisk/pulls/2544"},"html":{"href":"https://github.com/apache/incubator-openwhisk/pull/2544"},"issue":{"href":"https://api.github.com/repos/apache/incubator-openwhisk/issues/2544"},"comments":{"href":"https://api.github.com/repos/apache/incubator-openwhisk/issues/2544/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/incubator-openwhisk/pulls/2544/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/incubator-openwhisk/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/incubator-openwhisk/pulls/2544/commits"},"statuses":{"href":"https://api.github.com/repos/apache/incubator-openwhisk/statuses/10ebfa19e121d4ce6393245e6b2fa25a15e914ad"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"dubeejw"}}