https://github.com/subchen/snack-cli
command-line interfaces for node.js
https://github.com/subchen/snack-cli
Last synced: 5 months ago
JSON representation
command-line interfaces for node.js
- Host: GitHub
- URL: https://github.com/subchen/snack-cli
- Owner: subchen
- License: apache-2.0
- Created: 2015-05-06T08:45:29.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2019-03-12T12:46:38.000Z (over 7 years ago)
- Last Synced: 2025-09-27T00:37:58.722Z (9 months ago)
- Language: JavaScript
- Size: 32.2 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://travis-ci.org/subchen/snack-cli)
[](https://coveralls.io/r/subchen/snack-cli)
[](https://www.npmjs.com/package/snack-cli)
[](http://www.apache.org/licenses/LICENSE-2.0)
**SNACK-CLI** is command-line interfaces for node.js
# Install by npm
```shell
npm install snack-cli
```
# Example
```js
var cli = require('snack-cli');
var argv = cli
.name('sftp')
.version('1.0.0-beta')
.usage('[options] local remote')
.description('An sftp application written by node.js')
.option(' --host ', 'remote ssh hostname/ip')
.option(' --port ', 'remote ssh port', '22', cli.transformers.asInt)
.option('-u, --username ', 'username for authentication', 'root')
.option('-p, --password ', 'password for authentication')
.option(' --auto-mkdirs', 'mkdirs when dir not found')
.allowArgumentCount(2)
//.allowUnknownOption()
//.allowMissingRequiredOption()
.parse();
console.log(argv);
```
When you execute following cli:
```shell
sftp --host 192.168.0.254 -p 111111 --auto-mkdirs ./1.txt /tmp/1.txt
```
You will get:
```
{
'host': '192.168.0.254',
'port': 22,
'username': 'root',
'password': '111111',
'autoMkdirs': true,
'args': [
'./1.txt',
'/tmp/1.txt'
]
}
```
# Output help
When you execute following cli:
```shell
sftp --help
```
You will get:
```
Usage: sftp [options] local remote
An sftp application written by node.js
Options:
--host remote ssh hostname/ip
--port remote ssh port (default: 22)
-u, --username username for authentication (default: root)
-p, --password password for authentication
--auto-mkdirs mkdirs when dir not found
--version display version information and exit
--help display this help and exit
```
# License
Released under the [Apache 2 License](http://www.apache.org/licenses/LICENSE-2.0).