Skip to content

Commit

Permalink
feat: default to view given empty command
Browse files Browse the repository at this point in the history
This is inline with want an user would expect from the CLI. Instead of
having to write `30s v merge` we can simply use `30s merge`. This is
even more powerful when combined with autocomplete, which is a future
feature request.
  • Loading branch information
sQVe committed Aug 12, 2019
1 parent 90df30e commit b35c319
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ $ node lib/index.js <command> <query>
| `s` | `search` | Fuzzy search (RegExp) snippets by id |
| `t` | `tag` | View snippets by tag |
| `v` | `view` | View snippet with id |
| `*` | | View snippet with id |

#### Options

Expand All @@ -75,6 +76,7 @@ $ node lib/index.js <command> <query>

| Example | Description |
| :--------------------------- | ---------------------------------------------------------------------------- |
| `30s head` | View snippet with id `head` |
| `30s v head` | View snippet with id `head` |
| `30s view head` | View snippet with id `head` |
| `30s r` | View random snippet |
Expand Down
7 changes: 7 additions & 0 deletions src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,18 @@ addCommand ([
addAction ('view'),
])

addCommand ([
['command', '* [id]'],
['description', ['view snippet with id']],
addAction ('view'),
])

program.on ('--help', () =>
console.log (
[
'',
'Examples:',
' 30s head',
' 30s v head',
' 30s view head',
'',
Expand Down
2 changes: 1 addition & 1 deletion submodules/30-seconds-of-code
4 changes: 4 additions & 0 deletions test/integration/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ Commands:
s|search [options] [query] fuzzy search snippets by id
t|tag [options] [id] view snippets by tag
v|view [options] [id] view snippet with id
* [id] view snippet with id
Examples:
30s head
30s v head
30s view head
Expand All @@ -39,8 +41,10 @@ Commands:
s|search [options] [query] fuzzy search snippets by id
t|tag [options] [id] view snippets by tag
v|view [options] [id] view snippet with id
* [id] view snippet with id
Examples:
30s head
30s v head
30s view head
Expand Down

0 comments on commit b35c319

Please sign in to comment.