Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
sQVe committed Oct 14, 2018
1 parent 2c99dc6 commit bf46f1d
Show file tree
Hide file tree
Showing 7 changed files with 185 additions and 51 deletions.
Binary file added .github/demo.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions .travis.yml
Expand Up @@ -13,6 +13,7 @@ script:
- npm run format:guard
- npm run build
- npm run test
- npm run test:integration
after_success:
- scripts/update.sh
deploy:
Expand Down
131 changes: 128 additions & 3 deletions README.md
@@ -1,5 +1,130 @@
# 30-seconds-of-code-cli
# 30 seconds of code cli

[![Greenkeeper badge](https://badges.greenkeeper.io/sQVe/30-seconds-of-code-cli.svg)](https://greenkeeper.io/)
_A command-line application for [30 seconds of code](https://github.com/30-seconds/30-seconds-of-code/) snippets._

CLI for 30 seconds of code snippets
[![License](https://img.shields.io/badge/license-CC0--1.0-blue.svg)](https://github.com/sQVe/30-seconds-of-code-cli/blob/develop/LICENSE) [![Build Status](https://travis-ci.org/sQVe/30-seconds-of-code-cli.svg?branch=master)](https://travis-ci.org/sQVe/30-seconds-of-code-cli) [![Greenkeeper badge](https://badges.greenkeeper.io/sQVe/30-seconds-of-code-cli.svg)](https://greenkeeper.io/)

![Demo](/.github/demo.gif?raw=true)

<hr>

## Features

- Written in JavaScript (ES6)
- View, view by tag and search snippets
- Only show what you find necessary by picking a layout
- Colorful output or JSON
- Copy all code blocks to clipboard
- Automatically updates with new snippet changes
- Works on Mac, Linux and (maybe) Windows

## Installation

Pick one of the following options to install the command-line application:

#### Option 1: NPM / Yarn

```bash
npm install -g 30-seconds-of-code
```

```bash
yarn add -g 30-seconds-of-code
```

#### Option 2: Source

```bash
$ git clone git@github.com:sQVe/30-seconds-of-code-cli.git
$ cd 30-seconds-of-code-cli/
$ npm install
$ ./build/cli.sh <command> <query>
```

## Usage

#### Commands

```bash
s, search # fuzzy search snippets by id
t, tag # view snippets by tag
v, view # view snippet with id
```

#### Options

```bash
-c, --cp # copy code to clipboard
-j, --json # output in json format
-l, --layout # print in specified layout (default: "iced")
# i: id
# c: code
# e: example
# d: description
-h, --help # output usage information
```

#### Examples

```bash
30s view head # view snippet with id "head"
```

```bash
30s tag array # view snippets by tag "array"
```

```bash
30s search all # find all snippets that include "all"
```

```bash
30s view merge --json # view snippet with id "merge" and output as json
```

```bash
30s search all --layout ce # find all snippets that include "all" and print only code and example
```

```bash
30s view merge --cp # view snippet with id "merge" and copy it's code
```

## Contributing

#### Bug reports & feature requests

Please use the [issue tracker](https://github.com/sQVe/30-seconds-of-code-cli/issues) to report bugs or file feature requests.

#### Developing

PRs are more than welcome. Do the following to start helping out:

1. [Fork](https://help.github.com/articles/fork-a-repo/) this repository to your own GitHub account and then [clone](https://help.github.com/articles/cloning-a-repository/) it to your local device.
2. Run `npm install` in the created directory to install all necessary dependencies.

Optional steps:

3. Uninstall `30s` if it's already installed: `npm uninstall -g 30s`
4. Link it to the global module directory: `npm link`

#### Roadmap

See the [development board](https://github.com/sQVe/30-seconds-of-code-cli/projects/1) for a detailed development roadmap. Below are a short outline of important improvements:

- Setup coverage with `coveralls`
- Release with `semantic-release`
- Replace most helper logic by using `Ramda`
- Replace `commander` with basic `yargs` and own logic
- Autocomplete with `omelette`

## Thanks

Many thanks to the core team and all the contributers at [30-seconds-of-code](https://github.com/Chalarangelo/30-seconds-of-code) for creating an awesome curated collection of snippets.

## License

```
Creative Commons License
CC0 1.0 Universal
```
13 changes: 9 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -25,11 +25,11 @@
"format": "prettier-eslint --write '{**/*,*}.{js,jsx,json}'",
"format:guard": "prettier-eslint --list-different '{**/*,*}.{js,jsx,json}'",
"lint": "eslint '{**/*,*}.{js,jsx}'",
"prepublish": "npm run build",
"prepare": "npm run build",
"start": "babel-node src/cli.js",
"test": "jest",
"test:integration": "npm run build && jest test/cli.test.js --testPathIgnorePatterns",
"test:coverage": "jest --coverage",
"test:integration": "jest test/cli.test.js --testPathIgnorePatterns",
"test:watch": "jest --watch --onlyChanged"
},
"engines": {
Expand Down
19 changes: 11 additions & 8 deletions src/cli.js
Expand Up @@ -34,30 +34,33 @@ const addAction = action => [
: actions[action],
];
const commonOptions = [
['option', '-l, --layout <layout>', 'print in specified layout', 'iced'],
['option', '-c, --cp', 'copy code blocks', false],
['option', '-c, --cp', 'copy code to clipboard', false],
['option', '-j, --json', 'output in json format', false],
['option', '-l, --layout <layout>', 'print in specified layout', 'iced'],
];

program.version(version);

addCommand([
['command', 'search [query]'],
['description', ['Fuzzy search snippets']],
['command', 's [query]'],
['alias', 'search'],
['description', ['fuzzy search snippets by id']],
...commonOptions,
addAction('search'),
]);

addCommand([
['command', 'tag [id]'],
['description', ['View snippets related to tag']],
['command', 't [id]'],
['alias', 'tag'],
['description', ['view snippets by tag']],
...commonOptions,
addAction('tag'),
]);

addCommand([
['command', 'view [id]'],
['description', ['View snippet']],
['command', 'v [id]'],
['alias', 'view'],
['description', ['view snippet with id']],
...commonOptions,
addAction('view'),
]);
Expand Down
68 changes: 34 additions & 34 deletions test/__snapshots__/cli.test.js.snap
Expand Up @@ -4,13 +4,13 @@ exports[`Cli help option should print help page 1`] = `
"Usage: cli [options] [command]
Options:
-V, --version output the version number
-h, --help output usage information
-V, --version output the version number
-h, --help output usage information
Commands:
search [options] [query] Fuzzy search snippets
tag [options] [id] View snippets related to tag
view [options] [id] View snippet
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
Examples:
view all
Expand All @@ -22,13 +22,13 @@ exports[`Cli help option should print help page 2`] = `
"Usage: cli [options] [command]
Options:
-V, --version output the version number
-h, --help output usage information
-V, --version output the version number
-h, --help output usage information
Commands:
search [options] [query] Fuzzy search snippets
tag [options] [id] View snippets related to tag
view [options] [id] View snippet
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
Examples:
view all
Expand All @@ -37,73 +37,73 @@ Examples:
`;

exports[`Cli help option should print help page for search command 1`] = `
"Usage: search [options] [query]
"Usage: s|search [options] [query]
Fuzzy search snippets
fuzzy search snippets by id
Options:
-l, --layout <layout> print in specified layout (default: \\"iced\\")
-c, --cp copy code blocks
-c, --cp copy code to clipboard
-j, --json output in json format
-l, --layout <layout> print in specified layout (default: \\"iced\\")
-h, --help output usage information"
`;
exports[`Cli help option should print help page for search command 2`] = `
"Usage: search [options] [query]
"Usage: s|search [options] [query]
Fuzzy search snippets
fuzzy search snippets by id
Options:
-l, --layout <layout> print in specified layout (default: \\"iced\\")
-c, --cp copy code blocks
-c, --cp copy code to clipboard
-j, --json output in json format
-l, --layout <layout> print in specified layout (default: \\"iced\\")
-h, --help output usage information"
`;
exports[`Cli help option should print help page for tag command 1`] = `
"Usage: tag [options] [id]
"Usage: t|tag [options] [id]
View snippets related to tag
view snippets by tag
Options:
-l, --layout <layout> print in specified layout (default: \\"iced\\")
-c, --cp copy code blocks
-c, --cp copy code to clipboard
-j, --json output in json format
-l, --layout <layout> print in specified layout (default: \\"iced\\")
-h, --help output usage information"
`;
exports[`Cli help option should print help page for tag command 2`] = `
"Usage: tag [options] [id]
"Usage: t|tag [options] [id]
View snippets related to tag
view snippets by tag
Options:
-l, --layout <layout> print in specified layout (default: \\"iced\\")
-c, --cp copy code blocks
-c, --cp copy code to clipboard
-j, --json output in json format
-l, --layout <layout> print in specified layout (default: \\"iced\\")
-h, --help output usage information"
`;
exports[`Cli help option should print help page for view command 1`] = `
"Usage: view [options] [id]
"Usage: v|view [options] [id]
View snippet
view snippet with id
Options:
-l, --layout <layout> print in specified layout (default: \\"iced\\")
-c, --cp copy code blocks
-c, --cp copy code to clipboard
-j, --json output in json format
-l, --layout <layout> print in specified layout (default: \\"iced\\")
-h, --help output usage information"
`;
exports[`Cli help option should print help page for view command 2`] = `
"Usage: view [options] [id]
"Usage: v|view [options] [id]
View snippet
view snippet with id
Options:
-l, --layout <layout> print in specified layout (default: \\"iced\\")
-c, --cp copy code blocks
-c, --cp copy code to clipboard
-j, --json output in json format
-l, --layout <layout> print in specified layout (default: \\"iced\\")
-h, --help output usage information"
`;

0 comments on commit bf46f1d

Please sign in to comment.