{"action":"created","comment":{"url":"https://api.github.com/repos/apluslms/roman/pulls/comments/292901928","pull_request_review_id":248745143,"id":292901928,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDI5MjkwMTkyOA==","diff_hunk":"@@ -379,6 +413,142 @@ def config_print_action(context):\n         print(\"---\\n# project config\")\n         yaml_dump(get_config(context)._data, stdout)\n \n+def init_config(context):\n+    cwd = getcwd()\n+    # don't create if config already exists\n+    try:\n+        config_path = RomanConfig.find_from(cwd).path\n+        # if the folder is legacy, find_from won't error\n+        # so we need to check if the file actually exists\n+        if not isfile(config_path):\n+            raise RomanConfigError\n+        exit(1, \"{} already exists in {}.\\nNo new Roman config created.\".format(\n+            basename(config_path), cwd)\n+        )\n+    except RomanConfigError:\n+        filename = DEFAULT_NAME + \".yml\"\n+        config = LEGACY_CONFIG if is_legacy_configuration(cwd) else DEFAULT_CONFIG\n+        filepath = path_join(cwd, filename)\n+        with open(filepath, 'w') as outfile:\n+            yaml_dump(config, outfile)\n+        print(\"{} successfully created in {}\".format(filename, cwd))\n+\n+def set_args(context):\n+    if context.args.user == context.args.project:\n+        raise Exception(\"Choose either user settings or project settings\")\n+    if context.args.user:\n+        document = context.settings\n+    else:\n+        document = context.config\n+\n+    schema = document.validator.schema\n+    for val in context.args.values:\n+        try:\n+            key, val = val.split('=')\n+            parts = key.split(\".\")\n+            val_type = schema\n+            try:\n+                for part in parts:\n+                    val_type = val_type[\"properties\"][part]\n+                val_type = val_type[\"type\"]\n+                if val_type == \"integer\":\n+                    if val.isdigit():\n+                        val = int(val)\n+                    else:\n+                        raise TypeError(\"'\" + key + \"' should be an integer.\")\n+                elif val_type == \"boolean\":\n+                    if val.lower == \"true\" or val == \"1\":\n+                        val = True\n+                    elif val.lower == \"false\" or val == \"0\":\n+                        val = False\n+                    else:\n+                        raise TypeError(\"'\" + key + \"' should be a boolean.\")\n+            except KeyError:\n+                raise KeyError(\"'\" + key + \"' is not a key found in the schema.\")\n+            document.mlset(key, val)\n+        except ValueError:\n+            raise ValueError(\"Give values in format 'key=val'.\")\n+    document.validate()\n+    document.save()\n+\n+def del_args(context):\n+    if context.args.user == context.args.project:\n+        raise Exception(\"Choose either user settings or project settings\")\n+    if context.args.user:\n+        document = context.settings\n+    else:\n+        document = context.config\n+    for val in context.args.keys:\n+        document.mldel(val)\n+    document.validate()\n+    document.save()\n+\n+def add_step(context):\n+    args = context.args\n+    env = args.env\n+    if env:\n+        try:\n+            env = {a: b for a, b in [s.split('=') for s in env]}\n+        except ValueError:\n+            raise ValueError(\"env is a dict, so values need to be in key=val format, e.g. a=1 b=2\")\n+    step = {\n+        \"img\": args.img,\n+        \"cmd\": args.cmd,\n+        \"mnt\": args.mnt,\n+        \"env\": env,\n+        \"name\": args.name\n+    }\n+    nulls = [k for k in step if not step[k]]\n+    for k in nulls:\n+        del step[k]\n+    for k in step:\n+        if k != \"env\":\n+            step[k] = step[k][0]","path":"apluslms_roman/cli.py","position":null,"original_position":209,"commit_id":"2b10d8c47d18b0017e8ed4fc0da6c22e26bf5293","original_commit_id":"f2ec26f6e41091d51d7304ded3706adfca231c28","user":{"login":"raphendyr","id":2327687,"node_id":"MDQ6VXNlcjIzMjc2ODc=","avatar_url":"https://avatars1.githubusercontent.com/u/2327687?v=4","gravatar_id":"","url":"https://api.github.com/users/raphendyr","html_url":"https://github.com/raphendyr","followers_url":"https://api.github.com/users/raphendyr/followers","following_url":"https://api.github.com/users/raphendyr/following{/other_user}","gists_url":"https://api.github.com/users/raphendyr/gists{/gist_id}","starred_url":"https://api.github.com/users/raphendyr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/raphendyr/subscriptions","organizations_url":"https://api.github.com/users/raphendyr/orgs","repos_url":"https://api.github.com/users/raphendyr/repos","events_url":"https://api.github.com/users/raphendyr/events{/privacy}","received_events_url":"https://api.github.com/users/raphendyr/received_events","type":"User","site_admin":false},"body":"nargs=1 and nargs=None both mean \"there is only one argument\", but the value returned is in different format. IF I read the code correctly, nargs=None produces a single value and nargs=1 produces a list (else branch in following code).\r\n\r\nref: https://github.com/python/cpython/blob/master/Lib/argparse.py#L2375","created_at":"2019-06-12T13:05:22Z","updated_at":"2019-06-12T13:05:22Z","html_url":"https://github.com/apluslms/roman/pull/9#discussion_r292901928","pull_request_url":"https://api.github.com/repos/apluslms/roman/pulls/9","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/apluslms/roman/pulls/comments/292901928"},"html":{"href":"https://github.com/apluslms/roman/pull/9#discussion_r292901928"},"pull_request":{"href":"https://api.github.com/repos/apluslms/roman/pulls/9"}},"in_reply_to_id":290718430},"pull_request":{"url":"https://api.github.com/repos/apluslms/roman/pulls/9","id":284874147,"node_id":"MDExOlB1bGxSZXF1ZXN0Mjg0ODc0MTQ3","html_url":"https://github.com/apluslms/roman/pull/9","diff_url":"https://github.com/apluslms/roman/pull/9.diff","patch_url":"https://github.com/apluslms/roman/pull/9.patch","issue_url":"https://api.github.com/repos/apluslms/roman/issues/9","number":9,"state":"open","locked":false,"title":"commands for roman client","user":{"login":"ppessi","id":32612314,"node_id":"MDQ6VXNlcjMyNjEyMzE0","avatar_url":"https://avatars0.githubusercontent.com/u/32612314?v=4","gravatar_id":"","url":"https://api.github.com/users/ppessi","html_url":"https://github.com/ppessi","followers_url":"https://api.github.com/users/ppessi/followers","following_url":"https://api.github.com/users/ppessi/following{/other_user}","gists_url":"https://api.github.com/users/ppessi/gists{/gist_id}","starred_url":"https://api.github.com/users/ppessi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ppessi/subscriptions","organizations_url":"https://api.github.com/users/ppessi/orgs","repos_url":"https://api.github.com/users/ppessi/repos","events_url":"https://api.github.com/users/ppessi/events{/privacy}","received_events_url":"https://api.github.com/users/ppessi/received_events","type":"User","site_admin":false},"body":"","created_at":"2019-06-04T08:51:06Z","updated_at":"2019-06-12T13:05:22Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4ad81aafc0fbbbf4ebdcbbadac1ccc94fa15d5ae","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/apluslms/roman/pulls/9/commits","review_comments_url":"https://api.github.com/repos/apluslms/roman/pulls/9/comments","review_comment_url":"https://api.github.com/repos/apluslms/roman/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apluslms/roman/issues/9/comments","statuses_url":"https://api.github.com/repos/apluslms/roman/statuses/2b10d8c47d18b0017e8ed4fc0da6c22e26bf5293","head":{"label":"ppessi:milestone0.3","ref":"milestone0.3","sha":"2b10d8c47d18b0017e8ed4fc0da6c22e26bf5293","user":{"login":"ppessi","id":32612314,"node_id":"MDQ6VXNlcjMyNjEyMzE0","avatar_url":"https://avatars0.githubusercontent.com/u/32612314?v=4","gravatar_id":"","url":"https://api.github.com/users/ppessi","html_url":"https://github.com/ppessi","followers_url":"https://api.github.com/users/ppessi/followers","following_url":"https://api.github.com/users/ppessi/following{/other_user}","gists_url":"https://api.github.com/users/ppessi/gists{/gist_id}","starred_url":"https://api.github.com/users/ppessi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ppessi/subscriptions","organizations_url":"https://api.github.com/users/ppessi/orgs","repos_url":"https://api.github.com/users/ppessi/repos","events_url":"https://api.github.com/users/ppessi/events{/privacy}","received_events_url":"https://api.github.com/users/ppessi/received_events","type":"User","site_admin":false},"repo":{"id":179479311,"node_id":"MDEwOlJlcG9zaXRvcnkxNzk0NzkzMTE=","name":"roman","full_name":"ppessi/roman","private":false,"owner":{"login":"ppessi","id":32612314,"node_id":"MDQ6VXNlcjMyNjEyMzE0","avatar_url":"https://avatars0.githubusercontent.com/u/32612314?v=4","gravatar_id":"","url":"https://api.github.com/users/ppessi","html_url":"https://github.com/ppessi","followers_url":"https://api.github.com/users/ppessi/followers","following_url":"https://api.github.com/users/ppessi/following{/other_user}","gists_url":"https://api.github.com/users/ppessi/gists{/gist_id}","starred_url":"https://api.github.com/users/ppessi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ppessi/subscriptions","organizations_url":"https://api.github.com/users/ppessi/orgs","repos_url":"https://api.github.com/users/ppessi/repos","events_url":"https://api.github.com/users/ppessi/events{/privacy}","received_events_url":"https://api.github.com/users/ppessi/received_events","type":"User","site_admin":false},"html_url":"https://github.com/ppessi/roman","description":"Course material builder for online learning systems","fork":true,"url":"https://api.github.com/repos/ppessi/roman","forks_url":"https://api.github.com/repos/ppessi/roman/forks","keys_url":"https://api.github.com/repos/ppessi/roman/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ppessi/roman/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ppessi/roman/teams","hooks_url":"https://api.github.com/repos/ppessi/roman/hooks","issue_events_url":"https://api.github.com/repos/ppessi/roman/issues/events{/number}","events_url":"https://api.github.com/repos/ppessi/roman/events","assignees_url":"https://api.github.com/repos/ppessi/roman/assignees{/user}","branches_url":"https://api.github.com/repos/ppessi/roman/branches{/branch}","tags_url":"https://api.github.com/repos/ppessi/roman/tags","blobs_url":"https://api.github.com/repos/ppessi/roman/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ppessi/roman/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ppessi/roman/git/refs{/sha}","trees_url":"https://api.github.com/repos/ppessi/roman/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ppessi/roman/statuses/{sha}","languages_url":"https://api.github.com/repos/ppessi/roman/languages","stargazers_url":"https://api.github.com/repos/ppessi/roman/stargazers","contributors_url":"https://api.github.com/repos/ppessi/roman/contributors","subscribers_url":"https://api.github.com/repos/ppessi/roman/subscribers","subscription_url":"https://api.github.com/repos/ppessi/roman/subscription","commits_url":"https://api.github.com/repos/ppessi/roman/commits{/sha}","git_commits_url":"https://api.github.com/repos/ppessi/roman/git/commits{/sha}","comments_url":"https://api.github.com/repos/ppessi/roman/comments{/number}","issue_comment_url":"https://api.github.com/repos/ppessi/roman/issues/comments{/number}","contents_url":"https://api.github.com/repos/ppessi/roman/contents/{+path}","compare_url":"https://api.github.com/repos/ppessi/roman/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ppessi/roman/merges","archive_url":"https://api.github.com/repos/ppessi/roman/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ppessi/roman/downloads","issues_url":"https://api.github.com/repos/ppessi/roman/issues{/number}","pulls_url":"https://api.github.com/repos/ppessi/roman/pulls{/number}","milestones_url":"https://api.github.com/repos/ppessi/roman/milestones{/number}","notifications_url":"https://api.github.com/repos/ppessi/roman/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ppessi/roman/labels{/name}","releases_url":"https://api.github.com/repos/ppessi/roman/releases{/id}","deployments_url":"https://api.github.com/repos/ppessi/roman/deployments","created_at":"2019-04-04T10:52:42Z","updated_at":"2019-04-04T10:52:44Z","pushed_at":"2019-06-12T12:46:23Z","git_url":"git://github.com/ppessi/roman.git","ssh_url":"git@github.com:ppessi/roman.git","clone_url":"https://github.com/ppessi/roman.git","svn_url":"https://github.com/ppessi/roman","homepage":null,"size":1641,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":0,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"apluslms:milestone0.3","ref":"milestone0.3","sha":"5b6098320cd45ba0dfe5f32fc3a1e0c6444100e1","user":{"login":"apluslms","id":29550159,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI5NTUwMTU5","avatar_url":"https://avatars3.githubusercontent.com/u/29550159?v=4","gravatar_id":"","url":"https://api.github.com/users/apluslms","html_url":"https://github.com/apluslms","followers_url":"https://api.github.com/users/apluslms/followers","following_url":"https://api.github.com/users/apluslms/following{/other_user}","gists_url":"https://api.github.com/users/apluslms/gists{/gist_id}","starred_url":"https://api.github.com/users/apluslms/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apluslms/subscriptions","organizations_url":"https://api.github.com/users/apluslms/orgs","repos_url":"https://api.github.com/users/apluslms/repos","events_url":"https://api.github.com/users/apluslms/events{/privacy}","received_events_url":"https://api.github.com/users/apluslms/received_events","type":"Organization","site_admin":false},"repo":{"id":121278554,"node_id":"MDEwOlJlcG9zaXRvcnkxMjEyNzg1NTQ=","name":"roman","full_name":"apluslms/roman","private":false,"owner":{"login":"apluslms","id":29550159,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI5NTUwMTU5","avatar_url":"https://avatars3.githubusercontent.com/u/29550159?v=4","gravatar_id":"","url":"https://api.github.com/users/apluslms","html_url":"https://github.com/apluslms","followers_url":"https://api.github.com/users/apluslms/followers","following_url":"https://api.github.com/users/apluslms/following{/other_user}","gists_url":"https://api.github.com/users/apluslms/gists{/gist_id}","starred_url":"https://api.github.com/users/apluslms/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apluslms/subscriptions","organizations_url":"https://api.github.com/users/apluslms/orgs","repos_url":"https://api.github.com/users/apluslms/repos","events_url":"https://api.github.com/users/apluslms/events{/privacy}","received_events_url":"https://api.github.com/users/apluslms/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/apluslms/roman","description":"Course material builder for online learning systems","fork":false,"url":"https://api.github.com/repos/apluslms/roman","forks_url":"https://api.github.com/repos/apluslms/roman/forks","keys_url":"https://api.github.com/repos/apluslms/roman/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apluslms/roman/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apluslms/roman/teams","hooks_url":"https://api.github.com/repos/apluslms/roman/hooks","issue_events_url":"https://api.github.com/repos/apluslms/roman/issues/events{/number}","events_url":"https://api.github.com/repos/apluslms/roman/events","assignees_url":"https://api.github.com/repos/apluslms/roman/assignees{/user}","branches_url":"https://api.github.com/repos/apluslms/roman/branches{/branch}","tags_url":"https://api.github.com/repos/apluslms/roman/tags","blobs_url":"https://api.github.com/repos/apluslms/roman/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apluslms/roman/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apluslms/roman/git/refs{/sha}","trees_url":"https://api.github.com/repos/apluslms/roman/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apluslms/roman/statuses/{sha}","languages_url":"https://api.github.com/repos/apluslms/roman/languages","stargazers_url":"https://api.github.com/repos/apluslms/roman/stargazers","contributors_url":"https://api.github.com/repos/apluslms/roman/contributors","subscribers_url":"https://api.github.com/repos/apluslms/roman/subscribers","subscription_url":"https://api.github.com/repos/apluslms/roman/subscription","commits_url":"https://api.github.com/repos/apluslms/roman/commits{/sha}","git_commits_url":"https://api.github.com/repos/apluslms/roman/git/commits{/sha}","comments_url":"https://api.github.com/repos/apluslms/roman/comments{/number}","issue_comment_url":"https://api.github.com/repos/apluslms/roman/issues/comments{/number}","contents_url":"https://api.github.com/repos/apluslms/roman/contents/{+path}","compare_url":"https://api.github.com/repos/apluslms/roman/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apluslms/roman/merges","archive_url":"https://api.github.com/repos/apluslms/roman/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apluslms/roman/downloads","issues_url":"https://api.github.com/repos/apluslms/roman/issues{/number}","pulls_url":"https://api.github.com/repos/apluslms/roman/pulls{/number}","milestones_url":"https://api.github.com/repos/apluslms/roman/milestones{/number}","notifications_url":"https://api.github.com/repos/apluslms/roman/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apluslms/roman/labels{/name}","releases_url":"https://api.github.com/repos/apluslms/roman/releases{/id}","deployments_url":"https://api.github.com/repos/apluslms/roman/deployments","created_at":"2018-02-12T17:29:27Z","updated_at":"2019-05-23T13:05:41Z","pushed_at":"2019-06-12T12:46:25Z","git_url":"git://github.com/apluslms/roman.git","ssh_url":"git@github.com:apluslms/roman.git","clone_url":"https://github.com/apluslms/roman.git","svn_url":"https://github.com/apluslms/roman","homepage":null,"size":1562,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":4,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":3,"open_issues":4,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apluslms/roman/pulls/9"},"html":{"href":"https://github.com/apluslms/roman/pull/9"},"issue":{"href":"https://api.github.com/repos/apluslms/roman/issues/9"},"comments":{"href":"https://api.github.com/repos/apluslms/roman/issues/9/comments"},"review_comments":{"href":"https://api.github.com/repos/apluslms/roman/pulls/9/comments"},"review_comment":{"href":"https://api.github.com/repos/apluslms/roman/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apluslms/roman/pulls/9/commits"},"statuses":{"href":"https://api.github.com/repos/apluslms/roman/statuses/2b10d8c47d18b0017e8ed4fc0da6c22e26bf5293"}},"author_association":"NONE"}}
{"actor":{"display_login":"raphendyr"}}