improve typings and docs

This commit is contained in:
Philipp Kunz 2016-09-04 17:32:12 +02:00
parent 5c67015779
commit f8157ab8aa
6 changed files with 85 additions and 4 deletions

View File

@ -1,11 +1,20 @@
# smartcli
nodejs wrapper for CLI related tasks. TypeScript ready.
## Status
[![Build Status](https://travis-ci.org/pushrocks/smartcli.svg?branch=master)](https://travis-ci.org/pushrocks/smartcli)
## Availabililty
[![npm](https://push.rocks/assets/repo-button-npm.svg)](https://www.npmjs.com/package/smartcli)
[![git](https://push.rocks/assets/repo-button-git.svg)](https://gitlab.com/pushrocks/smartcli)
[![git](https://push.rocks/assets/repo-button-mirror.svg)](https://github.com/pushrocks/smartcli)
[![docs](https://push.rocks/assets/repo-button-docs.svg)](https://pushrocks.gitlab.io/smartcli/docs)
## Status for master
[![build status](https://gitlab.com/pushrocks/smartcli/badges/master/build.svg)](https://gitlab.com/pushrocks/smartcli/commits/master)
[![coverage report](https://gitlab.com/pushrocks/smartcli/badges/master/coverage.svg)](https://gitlab.com/pushrocks/smartcli/commits/master)
[![Dependency Status](https://david-dm.org/pushrocks/smartcli.svg)](https://david-dm.org/pushrocks/smartcli)
[![bitHound Overall Score](https://www.bithound.io/github/pushrocks/smartcli/badges/score.svg)](https://www.bithound.io/github/pushrocks/smartcli)
[![bitHound Dependencies](https://www.bithound.io/github/pushrocks/smartcli/badges/dependencies.svg)](https://www.bithound.io/github/pushrocks/smartcli/master/dependencies/npm)
[![bitHound Code](https://www.bithound.io/github/pushrocks/smartcli/badges/code.svg)](https://www.bithound.io/github/pushrocks/smartcli)
[![TypeScript](https://img.shields.io/badge/TypeScript-2.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/)
[![node](https://img.shields.io/badge/node->=%206.x.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/)
## Install the package
npm install smartcli --save

View File

@ -45,5 +45,8 @@ export declare class Smartcli {
* returns promise that is resolved when no commands are specified
*/
standardTask(): plugins.q.Promise<{}>;
/**
* start the process of evaluating commands
*/
startParse(): void;
}

View File

@ -90,10 +90,13 @@ class Smartcli {
});
return done.promise;
}
/**
* start the process of evaluating commands
*/
startParse() {
this.argv = this.argv.argv;
this.parseStarted.resolve();
}
}
exports.Smartcli = Smartcli;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRjbGkuY2xhc3Nlcy5zbWFydGNsaS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0Y2xpLmNsYXNzZXMuc21hcnRjbGkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sZ0JBQWdCLENBQUMsQ0FBQTtBQUV4QixNQUFZLE9BQU8sV0FBTSxvQkFBb0IsQ0FBQyxDQUFBO0FBRzlDLGlCQUFpQjtBQUNqQixzQkFBd0IsS0FBSyxDQUFDLENBQUE7QUFNN0IsQ0FBQztBQUVGO0lBVUk7UUFGQSxPQUFPO1FBQ1AsdUJBQWtCLEdBQUcsSUFBSSxlQUFTLEVBQXdCLENBQUM7UUFFdkQsSUFBSSxDQUFDLElBQUksR0FBRyxPQUFPLENBQUMsS0FBSyxDQUFDO1FBQzFCLElBQUksQ0FBQyxhQUFhLEdBQUcsT0FBTyxDQUFDLENBQUMsQ0FBQyxLQUFLLEVBQUUsQ0FBQztRQUN2QyxJQUFJLENBQUMsWUFBWSxHQUFHLE9BQU8sQ0FBQyxDQUFDLENBQUMsS0FBSyxFQUFFLENBQUM7SUFDMUMsQ0FBQzs7SUFFRDs7T0FFRztJQUNILFFBQVEsQ0FBQyxNQUFNLEVBQUMsUUFBUTtRQUNwQixJQUFJLENBQUMsSUFBSSxHQUFHLElBQUksQ0FBQyxJQUFJLENBQUMsS0FBSyxDQUFDLE1BQU0sRUFBQyxRQUFRLENBQUMsQ0FBQztJQUNqRCxDQUFDOztJQUVEOzs7O09BSUc7SUFDSCxVQUFVLENBQUMsYUFBa0M7UUFDekMsSUFBSSxJQUFJ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UM7UUFDUCxNQUFNLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQztJQUN4QixDQUFDO0lBRUQ7O09BRUc7SUFDSCxVQUFVO1FBQ04sSUFBSSxDQUFDLElBQUksR0FBRyxJQUFJLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQztRQUMzQixJQUFJLENBQUMsWUFBWSxDQUFDLE9BQU8sRUFBRSxDQUFDO0lBQ2hDLENBQUM7QUFFTCxDQUFDO0FBckdZLGdCQUFRLFdBcUdwQixDQUFBIn0=

15
docs/book.json Normal file
View File

@ -0,0 +1,15 @@
{
"structure": {
"readme": "index.md"
},
"plugins": [
"tonic",
"edit-link"
],
"pluginsConfig": {
"edit-link": {
"base": "https://gitlab.com/pushrocks/npmts/edit/master/docs/",
"label": "Edit on GitLab"
}
}
}

47
docs/index.md Normal file
View File

@ -0,0 +1,47 @@
# smartcli
nodejs wrapper for CLI related tasks. TypeScript ready.
## Availabililty
[![npm](https://push.rocks/assets/repo-button-npm.svg)](https://www.npmjs.com/package/smartcli)
[![git](https://push.rocks/assets/repo-button-git.svg)](https://gitlab.com/pushrocks/smartcli)
[![git](https://push.rocks/assets/repo-button-mirror.svg)](https://github.com/pushrocks/smartcli)
[![docs](https://push.rocks/assets/repo-button-docs.svg)](https://pushrocks.gitlab.io/smartcli/docs)
## Status for master
[![build status](https://gitlab.com/pushrocks/smartcli/badges/master/build.svg)](https://gitlab.com/pushrocks/smartcli/commits/master)
[![coverage report](https://gitlab.com/pushrocks/smartcli/badges/master/coverage.svg)](https://gitlab.com/pushrocks/smartcli/commits/master)
[![Dependency Status](https://david-dm.org/pushrocks/smartcli.svg)](https://david-dm.org/pushrocks/smartcli)
[![bitHound Dependencies](https://www.bithound.io/github/pushrocks/smartcli/badges/dependencies.svg)](https://www.bithound.io/github/pushrocks/smartcli/master/dependencies/npm)
[![bitHound Code](https://www.bithound.io/github/pushrocks/smartcli/badges/code.svg)](https://www.bithound.io/github/pushrocks/smartcli)
[![TypeScript](https://img.shields.io/badge/TypeScript-2.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/)
[![node](https://img.shields.io/badge/node->=%206.x.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/)
## Install the package
npm install smartcli --save
## Usage
this plugin tries to establish some logic in which CLI tools work.
take the following commandline input:
```
mytool function argument1 argument2 --option1 -o2 option2Value
```
* 'mytool' obviously is the tool (like git)
* function is the main thing the tool shall do (like commit)
* argument1 and argument2 are arguments
* option1 is a longform option you can add (like --message for message)
* optionValue is the referenced option value (like a commit message)
```typescript
import {Smartcli} from "smartcli"
mySmartcli = new Smartcli();
mySmartcli.standardTask()
.then(argvArg => {
// do something if program is called without an command
});
mySmartcli.question
```

View File

@ -104,6 +104,10 @@ export class Smartcli {
});
return done.promise;
}
/**
* start the process of evaluating commands
*/
startParse(){
this.argv = this.argv.argv;
this.parseStarted.resolve();