-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5c92f05
commit 7551f9d
Showing
4 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); |