Skip to content

Commit

Permalink
New: add CLI tool
Browse files Browse the repository at this point in the history
  • Loading branch information
jacoborus committed Apr 27, 2016
1 parent 33ab937 commit aa663ee
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 6 deletions.
40 changes: 35 additions & 5 deletions README.md
@@ -1,17 +1,19 @@
hexterm
=======

Convert hexadecimal color codes to Xterm
Get the xterm closest color to a hexadecimal color

## Install
## Usage

### Programatically

Clone, download and extract or install with npm
Install locally

```sh
npm install hexterm
```

## Usage
Require `hexterm` and pass a string to it

```js
const hexterm = require('hexterm')
Expand All @@ -24,7 +26,35 @@ hexterm('#ff0') // 11
```


<br><br>
### CLI

Install globally

```sh
npm install -g hexterm
```

Call from your shell: `hexterm <color>`

```sh
hexterm 005fd7
```

Remember to wrap the color code between quotes if has numeral prefix (`#`)

```sh
hexterm '#ff0'
```

## Test

Install dev-dependencies and run tests

```sh
npm install && npm tst
```

<br>

---

Expand Down
14 changes: 14 additions & 0 deletions bin/hexterm
@@ -0,0 +1,14 @@
#!/usr/bin/env node

'use strict'

const hexterm = require('../hexterm.js')
let out = ''
try {
out += hexterm(process.argv[2])
} catch (err) {
process.stderr.write(`(hexterm) Error: ${err}\n`)
process.exit(1)
}

process.stdout.write(`${out}\n`)
5 changes: 4 additions & 1 deletion package.json
@@ -1,12 +1,15 @@
{
"name": "hexterm",
"version": "1.1.1",
"version": "1.2.0",
"description": "Convert hex colors to closest xterm",
"main": "hexterm.js",
"scripts": {
"test": "node tests.js"
},
"keywords": ["hex", "colors", "xterm", "convert"],
"bin": {
"hexterm": "./bin/hexterm"
},
"author": "Jacobo Tabernero - http://jacoborus.codes",
"license": "MIT",
"homepage": "https://github.com/jacoborus/hexterm",
Expand Down

0 comments on commit aa663ee

Please sign in to comment.