1 | # 30s
|
2 |
|
3 | _A command-line application for [`30 seconds of code`](https://github.com/30-seconds/30-seconds-of-code/) snippets._
|
4 |
|
5 | [![NPM](https://img.shields.io/npm/v/30s.svg)](https://www.npmjs.com/package/30s) [![build status](https://travis-ci.org/sQVe/30s.svg?branch=master)](https://travis-ci.org/sQVe/30s) [![codecov](https://codecov.io/gh/sQVe/30s/branch/develop/graph/badge.svg)](https://codecov.io/gh/sQVe/30s) [![dependabot status](https://api.dependabot.com/badges/status?host=github&repo=sQVe/30s)](https://dependabot.com) [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release) [![license](https://img.shields.io/badge/license-CC0--1.0-blue.svg)](https://github.com/sQVe/30s/blob/develop/LICENSE)
|
6 |
|
7 | ![Demo](/.github/demo.gif?raw=true)
|
8 |
|
9 | <hr>
|
10 |
|
11 | ## Features
|
12 |
|
13 | - Written in JavaScript (ES6)
|
14 | - View, view by tag and search snippets
|
15 | - Show what you find necessary by picking a layout
|
16 | - Colorful output or JSON
|
17 | - Copy all code to clipboard
|
18 | - Automatically updates with new snippet changes
|
19 | - Works on Linux, Mac and Windows
|
20 |
|
21 | ## Installation
|
22 |
|
23 | Pick one of the following options to install the command-line application:
|
24 |
|
25 | #### Option 1: NPM / Yarn
|
26 |
|
27 | ```bash
|
28 | npm install -g 30s
|
29 | ```
|
30 |
|
31 | ```bash
|
32 | yarn add -g 30s
|
33 | ```
|
34 |
|
35 | #### Option 2: Source
|
36 |
|
37 | ```bash
|
38 | $ git clone git@github.com:sQVe/30s.git
|
39 | $ cd 30s/
|
40 | $ npm install
|
41 | $ node lib/index.js <command> <query>
|
42 | ```
|
43 |
|
44 | ## Usage
|
45 |
|
46 | #### Commands
|
47 |
|
48 | | Short version | Long version | Description |
|
49 | | :-----------: | :----------: | ------------------------------------ |
|
50 | | `r` | `random` | View random snippet |
|
51 | | `s` | `search` | Fuzzy search (RegExp) snippets by id |
|
52 | | `t` | `tag` | View snippets by tag |
|
53 | | `v` | `view` | View snippet with id |
|
54 | | `*` | | View snippet with id |
|
55 |
|
56 | #### Options
|
57 |
|
58 | | Short version | Long version | Description |
|
59 | | :-----------: | :----------: | ---------------------------------------------------------------- |
|
60 | | `-c` | `--cp` | Copy snippet code to clipboard |
|
61 | | `-j` | `--json` | Print output in JSON format |
|
62 | | `-l` | `--layout` | Print output with specified [layout](#layout) (default: "itced") |
|
63 | | `-h` | `--help` | Output usage information |
|
64 |
|
65 | ##### Layout
|
66 |
|
67 | | Layout key | Description |
|
68 | | :--------: | -------------------------- |
|
69 | | `i` | Output snippet id |
|
70 | | `t` | Output snippet tags |
|
71 | | `c` | Output snippet code |
|
72 | | `e` | Output snippet examples |
|
73 | | `d` | Output snippet description |
|
74 |
|
75 | #### Examples
|
76 |
|
77 | | Example | Description |
|
78 | | :--------------------------- | ---------------------------------------------------------------------------- |
|
79 | | `30s head` | View snippet with id `head` |
|
80 | | `30s v head` | View snippet with id `head` |
|
81 | | `30s view head` | View snippet with id `head` |
|
82 | | `30s r` | View random snippet |
|
83 | | `30s random` | View random snippet |
|
84 | | `30s t array` | View snippets by tag `array` |
|
85 | | `30s tag array` | View snippets by tag `array` |
|
86 | | `30s s all` | Find all snippets with an id that contains `all` |
|
87 | | `30s search all` | Find all snippets with an id that contains `all` |
|
88 | | `30s view merge --cp` | View snippet with id `merge` and copy its code |
|
89 | | `30s view merge --json` | View snippet with id `merge` and output as JSON |
|
90 | | `30s search all --layout ce` | Find all snippets with an id that contains `all` and output code and example |
|
91 |
|
92 | ## Contributing
|
93 |
|
94 | #### Bug reports & feature requests
|
95 |
|
96 | Please use the [issue tracker](https://github.com/sQVe/30s/issues) to report bugs or file feature requests.
|
97 |
|
98 | #### Developing
|
99 |
|
100 | Pull requests are more than welcome. Do the following to start helping out:
|
101 |
|
102 | 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.
|
103 | 2. Run `npm install` in the created directory to install all necessary dependencies.
|
104 |
|
105 | Optional steps:
|
106 |
|
107 | 3. Uninstall `30s` if it's already installed: `npm uninstall -g 30s`
|
108 | 4. Link it to the global module directory: `npm link`
|
109 |
|
110 | #### Style guide & conventions
|
111 |
|
112 | Try to follow [functional programming](https://en.wikipedia.org/wiki/Functional_programming) best practices. Use pure functions and [`Ramda`](https://github.com/ramda/ramda) when possible.
|
113 |
|
114 | Write commits following: [Angular Commit Message Conventions](https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#-git-commit-guidelines). This enables us to automatically release new versions together with [`semantic-release`](https://github.com/semantic-release/semantic-release) on `fix` and `feat` commit types.
|
115 |
|
116 | [`prettier`](https://github.com/prettier/prettier) and [`eslint-config-sqve`](https://github.com/sQVe/eslint-config-sqve) (a config based on [`standardjs`](https://standardjs.com)) enforces our styling and formatting. It runs automatically on `pre-commit` and is also checked for issues on **Travis CI**.
|
117 |
|
118 | #### Roadmap
|
119 |
|
120 | See the [development board](https://github.com/sQVe/30s/projects/1) for a detailed development roadmap. Below are a short outline of important improvements:
|
121 |
|
122 | - Autocomplete with `omelette`
|
123 | - Replace `commander` with basic `yargs` and own logic
|
124 |
|
125 | ## Thanks
|
126 |
|
127 | A big thank you 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.
|
128 |
|
129 | ## License
|
130 |
|
131 | ```
|
132 | Creative Commons License
|
133 | CC0 1.0 Universal
|
134 | ```
|