Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Option | Usage | Type
--- | --- | ---
`-n`, `--number` | **Required** | `Number`
`-R`, `--reaction` | **Required** | `String`
`-c`, `--comment` | *Optional* | `String`
`-i`, `--image` | *Optional* | `String`
`-r`, `--repo` | *Optional* | `String`
`-u`, `--user` | *Optional* | `String`
Expand All @@ -40,6 +41,12 @@ Option | Usage | Type
gh gif 75 --reaction happy
```

You can also use --comment

```
gh gif 75 --comment "This is cool" --reaction congratulation
```

* Comment on pull request/issue #75 of a certain repo with a surprised reaction.

```
Expand Down
13 changes: 12 additions & 1 deletion bin/gif.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,15 @@ Gif.DETAILS = {
'image': String,
'number': [Number, Array],
'reaction': String,
'comment': String,
'repo': String,
'user': String
},
shorthands: {
'i': [ '--image' ],
'n': [ '--number' ],
'R': [ '--reaction' ],
'c': [ '--comment' ],
'r': [ '--repo' ],
'u': [ '--user' ]
},
Expand All @@ -59,6 +61,14 @@ Gif.prototype.run = function() {
var instance = this,
options = instance.options;

if (options.comment && !options.reaction) {
logger.logTemplate('{{prefix}} [error] you forgot the --reaction options (shortcut -R)', {
options: options
});

return false;
}

if (options.image) {
logger.logTemplate('{{prefix}} [info] Adding comment on {{greenBright "#" options.number}}', {
options: options
Expand Down Expand Up @@ -89,7 +99,8 @@ Gif.prototype.image = function(image, opt_callback) {

operations = [
function(callback) {
options.comment = '![](' + image + ')';
options.comment = (options.comment)? options.comment + '<br>' : '';
options.comment += '![](' + image + ')';
instance.issue.comment(callback);
}
];
Expand Down