{"action":"created","comment":{"url":"https://api.github.com/repos/ubuntu-core/snapcraft/pulls/comments/58897594","id":58897594,"diff_hunk":"@@ -123,13 +130,53 @@ def main():\n         common.set_target_machine(args['--target-arch'])\n \n     try:\n-        commands.load(cmd).main(argv=args['ARGS'])\n+        run(args)\n     except Exception as e:\n         if args['--debug']:\n             raise\n \n         sys.exit(textwrap.fill(str(e)))\n \n \n+def _get_lifecycle_command(args):\n+    lifecycle_commands = ['pull', 'build', 'stage', 'strip']\n+    lifecycle_command = [k for k in lifecycle_commands if args[k]]\n+    if len(lifecycle_command) == 0:\n+        return None\n+    return lifecycle_command[0]\n+\n+\n+def _get_command_from_arg(args):\n+    functions = {\n+        'cleanbuild': snapcraft.lifecycle.cleanbuild,\n+        'init': snapcraft.lifecycle.init,\n+        'login': snapcraft.login,\n+        'logout': snapcraft.logout,\n+        'list-plugins': _list_plugins,\n+    }\n+    function = [k for k in functions if args[k]]\n+    if len(function) == 0:\n+        return None\n+    return functions[function[0]]\n+\n+\n+def run(args):\n+    lifecycle_command = _get_lifecycle_command(args)\n+    argless_command = _get_command_from_arg(args)\n+    if lifecycle_command:\n+        snapcraft.lifecycle.execute(lifecycle_command, args['<part>'])\n+    elif argless_command:\n+        argless_command()\n+    elif args['clean']:\n+        snapcraft.lifecycle.clean(args['<part>'], args['--step'])\n+    elif args['upload']:\n+        snapcraft.upload(args['<snap-file>'])\n+    elif args['help']:\n+        snapcraft.topic_help(args['<topic>'] or args['<plugin>'],\n+                             args['--devel'], args['topics'])\n+    else:  # snap of default:","path":"snapcraft/main.py","position":201,"original_position":194,"commit_id":"108e4e85eb16553640d7106dd004be278cc2ad63","original_commit_id":"71398bd40679e08f4a3233187e516894d69e7242","user":{"login":"sergiusens","id":1146853,"avatar_url":"https://avatars.githubusercontent.com/u/1146853?v=3","gravatar_id":"","url":"https://api.github.com/users/sergiusens","html_url":"https://github.com/sergiusens","followers_url":"https://api.github.com/users/sergiusens/followers","following_url":"https://api.github.com/users/sergiusens/following{/other_user}","gists_url":"https://api.github.com/users/sergiusens/gists{/gist_id}","starred_url":"https://api.github.com/users/sergiusens/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sergiusens/subscriptions","organizations_url":"https://api.github.com/users/sergiusens/orgs","repos_url":"https://api.github.com/users/sergiusens/repos","events_url":"https://api.github.com/users/sergiusens/events{/privacy}","received_events_url":"https://api.github.com/users/sergiusens/received_events","type":"User","site_admin":false},"body":"I wanted to say \"or\" but \"by\" is better :-)\n\nEl 07/04/16 a las 12:58, Kyle Fazzari escribió:\n> In snapcraft/main.py\n> <https://github.com/ubuntu-core/snapcraft/pull/433#discussion_r58897251>:\n> \n>> +\n>> +def run(args):\n>> +    lifecycle_command = _get_lifecycle_command(args)\n>> +    argless_command = _get_command_from_arg(args)\n>> +    if lifecycle_command:\n>> +        snapcraft.lifecycle.execute(lifecycle_command, args['<part>'])\n>> +    elif argless_command:\n>> +        argless_command()\n>> +    elif args['clean']:\n>> +        snapcraft.lifecycle.clean(args['<part>'], args['--step'])\n>> +    elif args['upload']:\n>> +        snapcraft.upload(args['<snap-file>'])\n>> +    elif args['help']:\n>> +        snapcraft.topic_help(args['<topic>'] or args['<plugin>'],\n>> +                             args['--devel'], args['topics'])\n>> +    else:  # snap of default:\n> \n> s/snap of default/snap by default/\n> \n> —\n> You are receiving this because you authored the thread.\n> Reply to this email directly or view it on GitHub\n> <https://github.com/ubuntu-core/snapcraft/pull/433/files/71398bd40679e08f4a3233187e516894d69e7242#r58897251>\n> \n\n","created_at":"2016-04-07T16:00:34Z","updated_at":"2016-04-07T16:00:35Z","html_url":"https://github.com/ubuntu-core/snapcraft/pull/433#discussion_r58897594","pull_request_url":"https://api.github.com/repos/ubuntu-core/snapcraft/pulls/433","_links":{"self":{"href":"https://api.github.com/repos/ubuntu-core/snapcraft/pulls/comments/58897594"},"html":{"href":"https://github.com/ubuntu-core/snapcraft/pull/433#discussion_r58897594"},"pull_request":{"href":"https://api.github.com/repos/ubuntu-core/snapcraft/pulls/433"}}},"pull_request":{"url":"https://api.github.com/repos/ubuntu-core/snapcraft/pulls/433","id":65565887,"html_url":"https://github.com/ubuntu-core/snapcraft/pull/433","diff_url":"https://github.com/ubuntu-core/snapcraft/pull/433.diff","patch_url":"https://github.com/ubuntu-core/snapcraft/pull/433.patch","issue_url":"https://api.github.com/repos/ubuntu-core/snapcraft/issues/433","number":433,"state":"open","locked":false,"title":"Converge all commands into one","user":{"login":"sergiusens","id":1146853,"avatar_url":"https://avatars.githubusercontent.com/u/1146853?v=3","gravatar_id":"","url":"https://api.github.com/users/sergiusens","html_url":"https://github.com/sergiusens","followers_url":"https://api.github.com/users/sergiusens/followers","following_url":"https://api.github.com/users/sergiusens/following{/other_user}","gists_url":"https://api.github.com/users/sergiusens/gists{/gist_id}","starred_url":"https://api.github.com/users/sergiusens/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sergiusens/subscriptions","organizations_url":"https://api.github.com/users/sergiusens/orgs","repos_url":"https://api.github.com/users/sergiusens/repos","events_url":"https://api.github.com/users/sergiusens/events{/privacy}","received_events_url":"https://api.github.com/users/sergiusens/received_events","type":"User","site_admin":false},"body":"LP: #1567058\r\nLP: #1567041\r\n\r\nSigned-off-by: Sergio Schvezov <sergio.schvezov@ubuntu.com>","created_at":"2016-04-07T02:38:29Z","updated_at":"2016-04-07T16:00:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e1728701b3c137a3a9a5f91685e59e78f0a2a4eb","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ubuntu-core/snapcraft/pulls/433/commits","review_comments_url":"https://api.github.com/repos/ubuntu-core/snapcraft/pulls/433/comments","review_comment_url":"https://api.github.com/repos/ubuntu-core/snapcraft/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ubuntu-core/snapcraft/issues/433/comments","statuses_url":"https://api.github.com/repos/ubuntu-core/snapcraft/statuses/108e4e85eb16553640d7106dd004be278cc2ad63","head":{"label":"sergiusens:bugfix/1567058/merge-commands","ref":"bugfix/1567058/merge-commands","sha":"108e4e85eb16553640d7106dd004be278cc2ad63","user":{"login":"sergiusens","id":1146853,"avatar_url":"https://avatars.githubusercontent.com/u/1146853?v=3","gravatar_id":"","url":"https://api.github.com/users/sergiusens","html_url":"https://github.com/sergiusens","followers_url":"https://api.github.com/users/sergiusens/followers","following_url":"https://api.github.com/users/sergiusens/following{/other_user}","gists_url":"https://api.github.com/users/sergiusens/gists{/gist_id}","starred_url":"https://api.github.com/users/sergiusens/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sergiusens/subscriptions","organizations_url":"https://api.github.com/users/sergiusens/orgs","repos_url":"https://api.github.com/users/sergiusens/repos","events_url":"https://api.github.com/users/sergiusens/events{/privacy}","received_events_url":"https://api.github.com/users/sergiusens/received_events","type":"User","site_admin":false},"repo":{"id":45202272,"name":"snapcraft","full_name":"sergiusens/snapcraft","owner":{"login":"sergiusens","id":1146853,"avatar_url":"https://avatars.githubusercontent.com/u/1146853?v=3","gravatar_id":"","url":"https://api.github.com/users/sergiusens","html_url":"https://github.com/sergiusens","followers_url":"https://api.github.com/users/sergiusens/followers","following_url":"https://api.github.com/users/sergiusens/following{/other_user}","gists_url":"https://api.github.com/users/sergiusens/gists{/gist_id}","starred_url":"https://api.github.com/users/sergiusens/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sergiusens/subscriptions","organizations_url":"https://api.github.com/users/sergiusens/orgs","repos_url":"https://api.github.com/users/sergiusens/repos","events_url":"https://api.github.com/users/sergiusens/events{/privacy}","received_events_url":"https://api.github.com/users/sergiusens/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sergiusens/snapcraft","description":"Snapcraft is a delightful packaging tool","fork":true,"url":"https://api.github.com/repos/sergiusens/snapcraft","forks_url":"https://api.github.com/repos/sergiusens/snapcraft/forks","keys_url":"https://api.github.com/repos/sergiusens/snapcraft/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sergiusens/snapcraft/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sergiusens/snapcraft/teams","hooks_url":"https://api.github.com/repos/sergiusens/snapcraft/hooks","issue_events_url":"https://api.github.com/repos/sergiusens/snapcraft/issues/events{/number}","events_url":"https://api.github.com/repos/sergiusens/snapcraft/events","assignees_url":"https://api.github.com/repos/sergiusens/snapcraft/assignees{/user}","branches_url":"https://api.github.com/repos/sergiusens/snapcraft/branches{/branch}","tags_url":"https://api.github.com/repos/sergiusens/snapcraft/tags","blobs_url":"https://api.github.com/repos/sergiusens/snapcraft/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sergiusens/snapcraft/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sergiusens/snapcraft/git/refs{/sha}","trees_url":"https://api.github.com/repos/sergiusens/snapcraft/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sergiusens/snapcraft/statuses/{sha}","languages_url":"https://api.github.com/repos/sergiusens/snapcraft/languages","stargazers_url":"https://api.github.com/repos/sergiusens/snapcraft/stargazers","contributors_url":"https://api.github.com/repos/sergiusens/snapcraft/contributors","subscribers_url":"https://api.github.com/repos/sergiusens/snapcraft/subscribers","subscription_url":"https://api.github.com/repos/sergiusens/snapcraft/subscription","commits_url":"https://api.github.com/repos/sergiusens/snapcraft/commits{/sha}","git_commits_url":"https://api.github.com/repos/sergiusens/snapcraft/git/commits{/sha}","comments_url":"https://api.github.com/repos/sergiusens/snapcraft/comments{/number}","issue_comment_url":"https://api.github.com/repos/sergiusens/snapcraft/issues/comments{/number}","contents_url":"https://api.github.com/repos/sergiusens/snapcraft/contents/{+path}","compare_url":"https://api.github.com/repos/sergiusens/snapcraft/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sergiusens/snapcraft/merges","archive_url":"https://api.github.com/repos/sergiusens/snapcraft/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sergiusens/snapcraft/downloads","issues_url":"https://api.github.com/repos/sergiusens/snapcraft/issues{/number}","pulls_url":"https://api.github.com/repos/sergiusens/snapcraft/pulls{/number}","milestones_url":"https://api.github.com/repos/sergiusens/snapcraft/milestones{/number}","notifications_url":"https://api.github.com/repos/sergiusens/snapcraft/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sergiusens/snapcraft/labels{/name}","releases_url":"https://api.github.com/repos/sergiusens/snapcraft/releases{/id}","deployments_url":"https://api.github.com/repos/sergiusens/snapcraft/deployments","created_at":"2015-10-29T18:19:58Z","updated_at":"2016-01-28T18:31:38Z","pushed_at":"2016-04-07T15:58:07Z","git_url":"git://github.com/sergiusens/snapcraft.git","ssh_url":"git@github.com:sergiusens/snapcraft.git","clone_url":"https://github.com/sergiusens/snapcraft.git","svn_url":"https://github.com/sergiusens/snapcraft","homepage":null,"size":3470,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"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":"ubuntu-core:master","ref":"master","sha":"3959ca2b156eddd5136dfadad6514ef5a2c3f0e7","user":{"login":"ubuntu-core","id":15022473,"avatar_url":"https://avatars.githubusercontent.com/u/15022473?v=3","gravatar_id":"","url":"https://api.github.com/users/ubuntu-core","html_url":"https://github.com/ubuntu-core","followers_url":"https://api.github.com/users/ubuntu-core/followers","following_url":"https://api.github.com/users/ubuntu-core/following{/other_user}","gists_url":"https://api.github.com/users/ubuntu-core/gists{/gist_id}","starred_url":"https://api.github.com/users/ubuntu-core/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ubuntu-core/subscriptions","organizations_url":"https://api.github.com/users/ubuntu-core/orgs","repos_url":"https://api.github.com/users/ubuntu-core/repos","events_url":"https://api.github.com/users/ubuntu-core/events{/privacy}","received_events_url":"https://api.github.com/users/ubuntu-core/received_events","type":"Organization","site_admin":false},"repo":{"id":45199136,"name":"snapcraft","full_name":"ubuntu-core/snapcraft","owner":{"login":"ubuntu-core","id":15022473,"avatar_url":"https://avatars.githubusercontent.com/u/15022473?v=3","gravatar_id":"","url":"https://api.github.com/users/ubuntu-core","html_url":"https://github.com/ubuntu-core","followers_url":"https://api.github.com/users/ubuntu-core/followers","following_url":"https://api.github.com/users/ubuntu-core/following{/other_user}","gists_url":"https://api.github.com/users/ubuntu-core/gists{/gist_id}","starred_url":"https://api.github.com/users/ubuntu-core/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ubuntu-core/subscriptions","organizations_url":"https://api.github.com/users/ubuntu-core/orgs","repos_url":"https://api.github.com/users/ubuntu-core/repos","events_url":"https://api.github.com/users/ubuntu-core/events{/privacy}","received_events_url":"https://api.github.com/users/ubuntu-core/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ubuntu-core/snapcraft","description":"Snapcraft is a delightful packaging tool","fork":false,"url":"https://api.github.com/repos/ubuntu-core/snapcraft","forks_url":"https://api.github.com/repos/ubuntu-core/snapcraft/forks","keys_url":"https://api.github.com/repos/ubuntu-core/snapcraft/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ubuntu-core/snapcraft/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ubuntu-core/snapcraft/teams","hooks_url":"https://api.github.com/repos/ubuntu-core/snapcraft/hooks","issue_events_url":"https://api.github.com/repos/ubuntu-core/snapcraft/issues/events{/number}","events_url":"https://api.github.com/repos/ubuntu-core/snapcraft/events","assignees_url":"https://api.github.com/repos/ubuntu-core/snapcraft/assignees{/user}","branches_url":"https://api.github.com/repos/ubuntu-core/snapcraft/branches{/branch}","tags_url":"https://api.github.com/repos/ubuntu-core/snapcraft/tags","blobs_url":"https://api.github.com/repos/ubuntu-core/snapcraft/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ubuntu-core/snapcraft/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ubuntu-core/snapcraft/git/refs{/sha}","trees_url":"https://api.github.com/repos/ubuntu-core/snapcraft/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ubuntu-core/snapcraft/statuses/{sha}","languages_url":"https://api.github.com/repos/ubuntu-core/snapcraft/languages","stargazers_url":"https://api.github.com/repos/ubuntu-core/snapcraft/stargazers","contributors_url":"https://api.github.com/repos/ubuntu-core/snapcraft/contributors","subscribers_url":"https://api.github.com/repos/ubuntu-core/snapcraft/subscribers","subscription_url":"https://api.github.com/repos/ubuntu-core/snapcraft/subscription","commits_url":"https://api.github.com/repos/ubuntu-core/snapcraft/commits{/sha}","git_commits_url":"https://api.github.com/repos/ubuntu-core/snapcraft/git/commits{/sha}","comments_url":"https://api.github.com/repos/ubuntu-core/snapcraft/comments{/number}","issue_comment_url":"https://api.github.com/repos/ubuntu-core/snapcraft/issues/comments{/number}","contents_url":"https://api.github.com/repos/ubuntu-core/snapcraft/contents/{+path}","compare_url":"https://api.github.com/repos/ubuntu-core/snapcraft/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ubuntu-core/snapcraft/merges","archive_url":"https://api.github.com/repos/ubuntu-core/snapcraft/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ubuntu-core/snapcraft/downloads","issues_url":"https://api.github.com/repos/ubuntu-core/snapcraft/issues{/number}","pulls_url":"https://api.github.com/repos/ubuntu-core/snapcraft/pulls{/number}","milestones_url":"https://api.github.com/repos/ubuntu-core/snapcraft/milestones{/number}","notifications_url":"https://api.github.com/repos/ubuntu-core/snapcraft/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ubuntu-core/snapcraft/labels{/name}","releases_url":"https://api.github.com/repos/ubuntu-core/snapcraft/releases{/id}","deployments_url":"https://api.github.com/repos/ubuntu-core/snapcraft/deployments","created_at":"2015-10-29T17:23:15Z","updated_at":"2016-04-01T20:25:46Z","pushed_at":"2016-04-07T15:58:07Z","git_url":"git://github.com/ubuntu-core/snapcraft.git","ssh_url":"git@github.com:ubuntu-core/snapcraft.git","clone_url":"https://github.com/ubuntu-core/snapcraft.git","svn_url":"https://github.com/ubuntu-core/snapcraft","homepage":null,"size":3710,"stargazers_count":55,"watchers_count":55,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":41,"mirror_url":null,"open_issues_count":12,"forks":41,"open_issues":12,"watchers":55,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ubuntu-core/snapcraft/pulls/433"},"html":{"href":"https://github.com/ubuntu-core/snapcraft/pull/433"},"issue":{"href":"https://api.github.com/repos/ubuntu-core/snapcraft/issues/433"},"comments":{"href":"https://api.github.com/repos/ubuntu-core/snapcraft/issues/433/comments"},"review_comments":{"href":"https://api.github.com/repos/ubuntu-core/snapcraft/pulls/433/comments"},"review_comment":{"href":"https://api.github.com/repos/ubuntu-core/snapcraft/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ubuntu-core/snapcraft/pulls/433/commits"},"statuses":{"href":"https://api.github.com/repos/ubuntu-core/snapcraft/statuses/108e4e85eb16553640d7106dd004be278cc2ad63"}}}}