Skip to content

Commit

Permalink
Added cli module files
Browse files Browse the repository at this point in the history
  • Loading branch information
knutkirkhorn committed Nov 9, 2017
1 parent 5c92f05 commit 7551f9d
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 0 deletions.
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,25 @@
# gcd-cli
Get the greatest common devisor of two numbers CLI

## Installation
```
$ npm install --global @knutkirkhorn/gcd-cli
```

## Usage
```
$ gcd --help
Usage
$ gcd <number1> <number2>
Examples
$ gcd 12 20
$ gcd 13 234
```

## Related
- [@knutkirkhorn/gcd](https://github.com/Knutakir/gcd)

## Licence
MIT © [Knut Kirkhorn](LICENSE)
23 changes: 23 additions & 0 deletions cli.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env node
'use strict;'
const gcd = require('@knutkirkhorn/gcd');
const meow = require('meow');

const cli = meow(`
Usage
$ gcd <number1> <number2>
Examples
$ gcd 12 20
$ gcd 13 234
`);

const number1 = cli.input[0];
const number2 = cli.input[1];

if (!(number1 && number2)) {
console.log("You need to specify both number1 and number2.");
process.exit(1);
}

console.log(gcd(number1, number2));
35 changes: 35 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "gcd-cli",
"version": "1.0.0",
"description": "Get the greatest common devisor of two numbers",
"bin": {
"gcd": "cli.js",
"gcd-cli": "cli.js"
},
"scripts": {
"test": "ava"
},
"files": [
"cli.js"
],
"engines": {
"node": ">=4"
},
"keywords": [
"gcd",
"greatest",
"common",
"devisor",
"cli",
"math"
],
"author": "Knut Kirkhorn",
"license": "MIT",
"dependencies": {
"@knutkirkhorn/gcd": "^1.0.0",
"meow": "^3.7.0"
},
"devDependencies": {
"ava": "^0.23.0"
}
}
6 changes: 6 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import test from 'ava';
import m from '.';

test(t => {
t.pass();
});

0 comments on commit 7551f9d

Please sign in to comment.