{"action":"created","comment":{"url":"https://api.github.com/repos/Chocobozzz/PeerTube/pulls/comments/212223081","pull_request_review_id":148805316,"id":212223081,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxMjIyMzA4MQ==","diff_hunk":"@@ -0,0 +1,104 @@\n+import * as program from 'commander'\n+import * as inquirer from 'inquirer'\n+const Table = require('cli-table')\n+const cfg = require('application-config')('PeerTube/CLI')\n+const netrc = require('netrc-parser').default\n+let settings = {\n+  remotes: []\n+}\n+cfg.read((err, data) => {\n+  if (err) console.error(err)\n+  if (data.remotes) settings.remotes = data.remotes\n+})\n+\n+const setPassword = (url, username, password) => {\n+  netrc.loadSync()\n+  netrc.machines[url] = { login: username, password }\n+  netrc.save()\n+}\n+\n+program\n+  .usage('[command] [options]')\n+\n+program\n+  .command('add')\n+  .description('registers your accounts on remote instances for easier use')\n+  .option('-u, --url <url>', 'Server url')\n+  .option('-U, --username <username>', 'Username')\n+  .option('-p, --password <token>', 'Password')\n+  .action(options => {\n+    if (!options.url || !options.username) {\n+      if (!options.url) console.error('--url field is required.')\n+      if (!options.username) console.error('--username field is required.')\n+      process.exit(-1)\n+    }\n+    settings.remotes.push(options.url)\n+    cfg.write(settings, function (err) {\n+      if (err) console.error(err)\n+    })\n+\n+    if (!options.password) {\n+      inquirer","path":"server/tools/peertube-remote.ts","position":41,"original_position":41,"commit_id":"7ce4dbf94d5081e592321b25ffefa4eae8337ba3","original_commit_id":"7ce4dbf94d5081e592321b25ffefa4eae8337ba3","user":{"login":"Chocobozzz","id":5180488,"node_id":"MDQ6VXNlcjUxODA0ODg=","avatar_url":"https://avatars0.githubusercontent.com/u/5180488?v=4","gravatar_id":"","url":"https://api.github.com/users/Chocobozzz","html_url":"https://github.com/Chocobozzz","followers_url":"https://api.github.com/users/Chocobozzz/followers","following_url":"https://api.github.com/users/Chocobozzz/following{/other_user}","gists_url":"https://api.github.com/users/Chocobozzz/gists{/gist_id}","starred_url":"https://api.github.com/users/Chocobozzz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Chocobozzz/subscriptions","organizations_url":"https://api.github.com/users/Chocobozzz/orgs","repos_url":"https://api.github.com/users/Chocobozzz/repos","events_url":"https://api.github.com/users/Chocobozzz/events{/privacy}","received_events_url":"https://api.github.com/users/Chocobozzz/received_events","type":"User","site_admin":false},"body":"We already use `prompt` for password prompt (see `import-videos.ts`)","created_at":"2018-08-23T08:28:23Z","updated_at":"2018-08-23T08:28:28Z","html_url":"https://github.com/Chocobozzz/PeerTube/pull/941#discussion_r212223081","pull_request_url":"https://api.github.com/repos/Chocobozzz/PeerTube/pulls/941","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/Chocobozzz/PeerTube/pulls/comments/212223081"},"html":{"href":"https://github.com/Chocobozzz/PeerTube/pull/941#discussion_r212223081"},"pull_request":{"href":"https://api.github.com/repos/Chocobozzz/PeerTube/pulls/941"}}},"pull_request":{"url":"https://api.github.com/repos/Chocobozzz/PeerTube/pulls/941","id":209993067,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA5OTkzMDY3","html_url":"https://github.com/Chocobozzz/PeerTube/pull/941","diff_url":"https://github.com/Chocobozzz/PeerTube/pull/941.diff","patch_url":"https://github.com/Chocobozzz/PeerTube/pull/941.patch","issue_url":"https://api.github.com/repos/Chocobozzz/PeerTube/issues/941","number":941,"state":"open","locked":false,"title":"WIP: adding cli wrapper","user":{"login":"rigelk","id":6329880,"node_id":"MDQ6VXNlcjYzMjk4ODA=","avatar_url":"https://avatars0.githubusercontent.com/u/6329880?v=4","gravatar_id":"","url":"https://api.github.com/users/rigelk","html_url":"https://github.com/rigelk","followers_url":"https://api.github.com/users/rigelk/followers","following_url":"https://api.github.com/users/rigelk/following{/other_user}","gists_url":"https://api.github.com/users/rigelk/gists{/gist_id}","starred_url":"https://api.github.com/users/rigelk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rigelk/subscriptions","organizations_url":"https://api.github.com/users/rigelk/orgs","repos_url":"https://api.github.com/users/rigelk/repos","events_url":"https://api.github.com/users/rigelk/events{/privacy}","received_events_url":"https://api.github.com/users/rigelk/received_events","type":"User","site_admin":false},"body":"Time for a much not-needed PR!\r\n\r\nJoke aside, a CLI is a \"nice\" way to allow the end user to access scripts that are otherwise only accessible through reading the tools documentation (not that it should replace the tool documentation) or the package.json scripts.\r\n\r\nI also wanted to experiment with adding a subcommand, just to showcase different ways to add commands and provide an example for future scripts to be integrated in the CLI. In the end, adding a script = adding **one** line :slightly_smiling_face: \r\n\r\nBut I also wanted to decouple a bit the CLI from the rest of PeerTube's codebase. Spoiler: I didn't. There are numerous dependencies that take directly from PeerTube, and modularising them is out of scope. However, I did manage to add a subcommand without adding its dependencies to the main package.json, via a package I remanied for the occasion: 'summon-install', which basically installs the dependency at runtime. Dirty but it keeps the heavy dependencies of the CLI away from the PeerTube installation.\r\n\r\n---\r\n\r\nWhat I have added:\r\n\r\n- a 'remote' subcommand that un/registers instances' credentials and stores them in the .netrc for reuse by other commands. It also stores a few settings, but that's just the beginning for now.\r\n- a 'watch' subcommand that plays videos of any PeerTube instance in the terminal, in ascii art and with sound! (notice that it's a dependency downloaded and registered at runtime!)\r\n- a nice helper art for @Chocobozzz :wink: \r\n\r\n---\r\n\r\nToDo:\r\n\r\n- [ ] adapt the tools.md doc\r\n- [ ] refactor peertube-upload.ts, since I want it to get the login/token from .netrc if a remote instance is already registered\r\n- [ ] some tab completion?","created_at":"2018-08-22T00:46:00Z","updated_at":"2018-08-23T08:28:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"040373ad2a8bb0789e8cc8f956077a53f2662a39","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/Chocobozzz/PeerTube/pulls/941/commits","review_comments_url":"https://api.github.com/repos/Chocobozzz/PeerTube/pulls/941/comments","review_comment_url":"https://api.github.com/repos/Chocobozzz/PeerTube/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Chocobozzz/PeerTube/issues/941/comments","statuses_url":"https://api.github.com/repos/Chocobozzz/PeerTube/statuses/7ce4dbf94d5081e592321b25ffefa4eae8337ba3","head":{"label":"rigelk:cli-wrapper","ref":"cli-wrapper","sha":"7ce4dbf94d5081e592321b25ffefa4eae8337ba3","user":{"login":"rigelk","id":6329880,"node_id":"MDQ6VXNlcjYzMjk4ODA=","avatar_url":"https://avatars0.githubusercontent.com/u/6329880?v=4","gravatar_id":"","url":"https://api.github.com/users/rigelk","html_url":"https://github.com/rigelk","followers_url":"https://api.github.com/users/rigelk/followers","following_url":"https://api.github.com/users/rigelk/following{/other_user}","gists_url":"https://api.github.com/users/rigelk/gists{/gist_id}","starred_url":"https://api.github.com/users/rigelk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rigelk/subscriptions","organizations_url":"https://api.github.com/users/rigelk/orgs","repos_url":"https://api.github.com/users/rigelk/repos","events_url":"https://api.github.com/users/rigelk/events{/privacy}","received_events_url":"https://api.github.com/users/rigelk/received_events","type":"User","site_admin":false},"repo":{"id":114056832,"node_id":"MDEwOlJlcG9zaXRvcnkxMTQwNTY4MzI=","name":"PeerTube","full_name":"rigelk/PeerTube","owner":{"login":"rigelk","id":6329880,"node_id":"MDQ6VXNlcjYzMjk4ODA=","avatar_url":"https://avatars0.githubusercontent.com/u/6329880?v=4","gravatar_id":"","url":"https://api.github.com/users/rigelk","html_url":"https://github.com/rigelk","followers_url":"https://api.github.com/users/rigelk/followers","following_url":"https://api.github.com/users/rigelk/following{/other_user}","gists_url":"https://api.github.com/users/rigelk/gists{/gist_id}","starred_url":"https://api.github.com/users/rigelk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rigelk/subscriptions","organizations_url":"https://api.github.com/users/rigelk/orgs","repos_url":"https://api.github.com/users/rigelk/repos","events_url":"https://api.github.com/users/rigelk/events{/privacy}","received_events_url":"https://api.github.com/users/rigelk/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/rigelk/PeerTube","description":"[personal draft space to contribute to PeerTube]","fork":true,"url":"https://api.github.com/repos/rigelk/PeerTube","forks_url":"https://api.github.com/repos/rigelk/PeerTube/forks","keys_url":"https://api.github.com/repos/rigelk/PeerTube/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rigelk/PeerTube/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rigelk/PeerTube/teams","hooks_url":"https://api.github.com/repos/rigelk/PeerTube/hooks","issue_events_url":"https://api.github.com/repos/rigelk/PeerTube/issues/events{/number}","events_url":"https://api.github.com/repos/rigelk/PeerTube/events","assignees_url":"https://api.github.com/repos/rigelk/PeerTube/assignees{/user}","branches_url":"https://api.github.com/repos/rigelk/PeerTube/branches{/branch}","tags_url":"https://api.github.com/repos/rigelk/PeerTube/tags","blobs_url":"https://api.github.com/repos/rigelk/PeerTube/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rigelk/PeerTube/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rigelk/PeerTube/git/refs{/sha}","trees_url":"https://api.github.com/repos/rigelk/PeerTube/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rigelk/PeerTube/statuses/{sha}","languages_url":"https://api.github.com/repos/rigelk/PeerTube/languages","stargazers_url":"https://api.github.com/repos/rigelk/PeerTube/stargazers","contributors_url":"https://api.github.com/repos/rigelk/PeerTube/contributors","subscribers_url":"https://api.github.com/repos/rigelk/PeerTube/subscribers","subscription_url":"https://api.github.com/repos/rigelk/PeerTube/subscription","commits_url":"https://api.github.com/repos/rigelk/PeerTube/commits{/sha}","git_commits_url":"https://api.github.com/repos/rigelk/PeerTube/git/commits{/sha}","comments_url":"https://api.github.com/repos/rigelk/PeerTube/comments{/number}","issue_comment_url":"https://api.github.com/repos/rigelk/PeerTube/issues/comments{/number}","contents_url":"https://api.github.com/repos/rigelk/PeerTube/contents/{+path}","compare_url":"https://api.github.com/repos/rigelk/PeerTube/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rigelk/PeerTube/merges","archive_url":"https://api.github.com/repos/rigelk/PeerTube/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rigelk/PeerTube/downloads","issues_url":"https://api.github.com/repos/rigelk/PeerTube/issues{/number}","pulls_url":"https://api.github.com/repos/rigelk/PeerTube/pulls{/number}","milestones_url":"https://api.github.com/repos/rigelk/PeerTube/milestones{/number}","notifications_url":"https://api.github.com/repos/rigelk/PeerTube/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rigelk/PeerTube/labels{/name}","releases_url":"https://api.github.com/repos/rigelk/PeerTube/releases{/id}","deployments_url":"https://api.github.com/repos/rigelk/PeerTube/deployments","created_at":"2017-12-13T01:12:14Z","updated_at":"2018-05-16T09:44:30Z","pushed_at":"2018-08-23T00:01:48Z","git_url":"git://github.com/rigelk/PeerTube.git","ssh_url":"git@github.com:rigelk/PeerTube.git","clone_url":"https://github.com/rigelk/PeerTube.git","svn_url":"https://github.com/rigelk/PeerTube","homepage":"","size":13406,"stargazers_count":0,"watchers_count":0,"language":"TypeScript","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":{"key":"agpl-3.0","name":"GNU Affero General Public License v3.0","spdx_id":"AGPL-3.0","url":"https://api.github.com/licenses/agpl-3.0","node_id":"MDc6TGljZW5zZTE="},"forks":0,"open_issues":1,"watchers":0,"default_branch":"develop"}},"base":{"label":"Chocobozzz:develop","ref":"develop","sha":"9e91237655dfc2f7e2f03f77bb98992cfdd5c43f","user":{"login":"Chocobozzz","id":5180488,"node_id":"MDQ6VXNlcjUxODA0ODg=","avatar_url":"https://avatars0.githubusercontent.com/u/5180488?v=4","gravatar_id":"","url":"https://api.github.com/users/Chocobozzz","html_url":"https://github.com/Chocobozzz","followers_url":"https://api.github.com/users/Chocobozzz/followers","following_url":"https://api.github.com/users/Chocobozzz/following{/other_user}","gists_url":"https://api.github.com/users/Chocobozzz/gists{/gist_id}","starred_url":"https://api.github.com/users/Chocobozzz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Chocobozzz/subscriptions","organizations_url":"https://api.github.com/users/Chocobozzz/orgs","repos_url":"https://api.github.com/users/Chocobozzz/repos","events_url":"https://api.github.com/users/Chocobozzz/events{/privacy}","received_events_url":"https://api.github.com/users/Chocobozzz/received_events","type":"User","site_admin":false},"repo":{"id":45213667,"node_id":"MDEwOlJlcG9zaXRvcnk0NTIxMzY2Nw==","name":"PeerTube","full_name":"Chocobozzz/PeerTube","owner":{"login":"Chocobozzz","id":5180488,"node_id":"MDQ6VXNlcjUxODA0ODg=","avatar_url":"https://avatars0.githubusercontent.com/u/5180488?v=4","gravatar_id":"","url":"https://api.github.com/users/Chocobozzz","html_url":"https://github.com/Chocobozzz","followers_url":"https://api.github.com/users/Chocobozzz/followers","following_url":"https://api.github.com/users/Chocobozzz/following{/other_user}","gists_url":"https://api.github.com/users/Chocobozzz/gists{/gist_id}","starred_url":"https://api.github.com/users/Chocobozzz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Chocobozzz/subscriptions","organizations_url":"https://api.github.com/users/Chocobozzz/orgs","repos_url":"https://api.github.com/users/Chocobozzz/repos","events_url":"https://api.github.com/users/Chocobozzz/events{/privacy}","received_events_url":"https://api.github.com/users/Chocobozzz/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Chocobozzz/PeerTube","description":"Federated (ActivityPub) video streaming platform using P2P (BitTorrent) directly in the web browser with WebTorrent and Angular.","fork":false,"url":"https://api.github.com/repos/Chocobozzz/PeerTube","forks_url":"https://api.github.com/repos/Chocobozzz/PeerTube/forks","keys_url":"https://api.github.com/repos/Chocobozzz/PeerTube/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Chocobozzz/PeerTube/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Chocobozzz/PeerTube/teams","hooks_url":"https://api.github.com/repos/Chocobozzz/PeerTube/hooks","issue_events_url":"https://api.github.com/repos/Chocobozzz/PeerTube/issues/events{/number}","events_url":"https://api.github.com/repos/Chocobozzz/PeerTube/events","assignees_url":"https://api.github.com/repos/Chocobozzz/PeerTube/assignees{/user}","branches_url":"https://api.github.com/repos/Chocobozzz/PeerTube/branches{/branch}","tags_url":"https://api.github.com/repos/Chocobozzz/PeerTube/tags","blobs_url":"https://api.github.com/repos/Chocobozzz/PeerTube/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Chocobozzz/PeerTube/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Chocobozzz/PeerTube/git/refs{/sha}","trees_url":"https://api.github.com/repos/Chocobozzz/PeerTube/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Chocobozzz/PeerTube/statuses/{sha}","languages_url":"https://api.github.com/repos/Chocobozzz/PeerTube/languages","stargazers_url":"https://api.github.com/repos/Chocobozzz/PeerTube/stargazers","contributors_url":"https://api.github.com/repos/Chocobozzz/PeerTube/contributors","subscribers_url":"https://api.github.com/repos/Chocobozzz/PeerTube/subscribers","subscription_url":"https://api.github.com/repos/Chocobozzz/PeerTube/subscription","commits_url":"https://api.github.com/repos/Chocobozzz/PeerTube/commits{/sha}","git_commits_url":"https://api.github.com/repos/Chocobozzz/PeerTube/git/commits{/sha}","comments_url":"https://api.github.com/repos/Chocobozzz/PeerTube/comments{/number}","issue_comment_url":"https://api.github.com/repos/Chocobozzz/PeerTube/issues/comments{/number}","contents_url":"https://api.github.com/repos/Chocobozzz/PeerTube/contents/{+path}","compare_url":"https://api.github.com/repos/Chocobozzz/PeerTube/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Chocobozzz/PeerTube/merges","archive_url":"https://api.github.com/repos/Chocobozzz/PeerTube/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Chocobozzz/PeerTube/downloads","issues_url":"https://api.github.com/repos/Chocobozzz/PeerTube/issues{/number}","pulls_url":"https://api.github.com/repos/Chocobozzz/PeerTube/pulls{/number}","milestones_url":"https://api.github.com/repos/Chocobozzz/PeerTube/milestones{/number}","notifications_url":"https://api.github.com/repos/Chocobozzz/PeerTube/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Chocobozzz/PeerTube/labels{/name}","releases_url":"https://api.github.com/repos/Chocobozzz/PeerTube/releases{/id}","deployments_url":"https://api.github.com/repos/Chocobozzz/PeerTube/deployments","created_at":"2015-10-29T22:09:42Z","updated_at":"2018-08-23T07:41:29Z","pushed_at":"2018-08-23T07:41:27Z","git_url":"git://github.com/Chocobozzz/PeerTube.git","ssh_url":"git@github.com:Chocobozzz/PeerTube.git","clone_url":"https://github.com/Chocobozzz/PeerTube.git","svn_url":"https://github.com/Chocobozzz/PeerTube","homepage":"","size":13445,"stargazers_count":3807,"watchers_count":3807,"language":"TypeScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":317,"mirror_url":null,"archived":false,"open_issues_count":151,"license":{"key":"agpl-3.0","name":"GNU Affero General Public License v3.0","spdx_id":"AGPL-3.0","url":"https://api.github.com/licenses/agpl-3.0","node_id":"MDc6TGljZW5zZTE="},"forks":317,"open_issues":151,"watchers":3807,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/Chocobozzz/PeerTube/pulls/941"},"html":{"href":"https://github.com/Chocobozzz/PeerTube/pull/941"},"issue":{"href":"https://api.github.com/repos/Chocobozzz/PeerTube/issues/941"},"comments":{"href":"https://api.github.com/repos/Chocobozzz/PeerTube/issues/941/comments"},"review_comments":{"href":"https://api.github.com/repos/Chocobozzz/PeerTube/pulls/941/comments"},"review_comment":{"href":"https://api.github.com/repos/Chocobozzz/PeerTube/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Chocobozzz/PeerTube/pulls/941/commits"},"statuses":{"href":"https://api.github.com/repos/Chocobozzz/PeerTube/statuses/7ce4dbf94d5081e592321b25ffefa4eae8337ba3"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"Chocobozzz"}}