Skip to content

Commit

Permalink
☔ 0.2.0, Command-line mode
Browse files Browse the repository at this point in the history
  • Loading branch information
metowolf committed Oct 23, 2018
1 parent 1755285 commit f7eb8ae
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 7 deletions.
30 changes: 27 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,29 @@
</p>


## SMMS-cli
## Command-line Usage

### Installation

```bash
npm install smms-cli -g
```

### Usage

Upload a single image

```bash
smms dog.png
```

Display smms-cli version:

```bash
smms --version
```

## Module Usage

### Installation

Expand Down Expand Up @@ -123,6 +145,8 @@ imgur.delete(hash)
})
```

## License
## Author

**smms-cli** © [metowolf](https://github.com/metowolf), Released under the [MIT](./LICENSE) License.<br>

#### MIT
> Blog [@meto](https://i-meto.com) · GitHub [@metowolf](https://github.com/metowolf) · Twitter [@metowolf](https://twitter.com/metowolf) · Telegram Channel [@metooooo](https://t.me/metooooo)
38 changes: 38 additions & 0 deletions lib/cli.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env node

const fs = require('fs')
const meow = require('meow')
const smms = require('../')

const cli = meow(`
Usage
$ smms <filename>
Options
--version, -V show smms-cli version
Examples
$ smms example.png
$ smms -V
`, {
flags: {
version: {
alias: 'V'
}
}
})

if (cli.input.length === 0 && process.stdin.isTTY) {
console.error('filename required')
process.exit(1)
}

if (cli.input.length) {
smms
.upload(cli.input[0])
.then(res => console.log(res.data.url))
.catch(res => {
console.error(err)
process.exit(1)
})
}
11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
{
"name": "smms-cli",
"version": "0.1.1",
"version": "0.2.0",
"description": "Upload images to sm.ms",
"main": "lib/smms.js",
"repository": "https://github.com/metowolf/smms-cli.git",
"author": "metowolf <[email protected]>",
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/metowolf/smms-cli.git"
},
"author": "metowolf <[email protected]>",
"license": "MIT",
"bugs": {
"url": "https://github.com/metowolf/smms-cli/issues"
},
"dependencies": {
"meow": "^5.0.0",
"request": "^2.88.0",
"request-promise": "^4.2.2"
},
"scripts": {
"test": "cd test && node example.js"
},
"bin": {
"smms": "./lib/cli.js"
}
}

0 comments on commit f7eb8ae

Please sign in to comment.