From 69ac1a76e8666d49094796e4dd26936dd75bf1ac Mon Sep 17 00:00:00 2001 From: Zeno Rocha Date: Mon, 9 Sep 2013 23:35:59 -0300 Subject: [PATCH] Issue cmd: Add --browser flag --- README.md | 17 +++++++++++++++++ lib/cmds/issue.js | 10 ++++++++++ 2 files changed, 27 insertions(+) diff --git a/README.md b/README.md index 03711f3f..13d94a4d 100644 --- a/README.md +++ b/README.md @@ -483,6 +483,23 @@ gh is --list --label todo,bug gh is --list --user eduardolundgren --repo node-gh ``` +### 5. Open + +Option | Usage | Type +--- | --- | --- +`-B`, `--browser` | **Required** | `Boolean` +`-n`, `--number` | **Required** | `Number` +`-u`, `--user` | *Optional* | `String` +`-r`, `--repo` | *Optional* | `String` + +#### Examples + +* Open GitHub issue page in the browser. + + ``` +gh is 100 --browser + ``` + ## Repo ``` gh repo diff --git a/lib/cmds/issue.js b/lib/cmds/issue.js index fca94391..6a4c87c4 100644 --- a/lib/cmds/issue.js +++ b/lib/cmds/issue.js @@ -31,6 +31,7 @@ Issue.DETAILS = { options: { 'all' : Boolean, 'assignee' : String, + 'browser' : Boolean, 'close' : Boolean, 'comment' : String, 'detailed' : Boolean, @@ -50,6 +51,7 @@ Issue.DETAILS = { shorthands: { 'a': [ '--all' ], 'A': [ '--assignee' ], + 'B': [ '--browser' ], 'C': [ '--close' ], 'c': [ '--comment' ], 'd': [ '--detailed' ], @@ -88,6 +90,10 @@ Issue.prototype.run = function() { options.state = options.state || Issue.STATE_OPEN; + if (options.browser) { + instance.browser(options.user, options.repo, options.number); + } + if (options.close) { options.state = Issue.STATE_CLOSED; @@ -165,6 +171,10 @@ Issue.prototype.run = function() { }; +Issue.prototype.browser = function(user, repo, number) { + open('http://github.com/' + user + '/' + repo + '/issues/' + number); +}; + Issue.prototype.close = function(opt_callback) { var instance = this;