Comparing version 0.6.1 to 0.6.2
@@ -14,7 +14,7 @@ import { Terminal } from '../Terminal'; | ||
} | ||
export declare type NextFunctionError = (error?: Error) => void; | ||
export declare type NextFunctionSuccess = () => void; | ||
export declare type NextFunction = NextFunctionSuccess | NextFunctionError; | ||
export declare type CommandFunction = (context: Context, terminal: Terminal, nextFunction: NextFunction) => void | Promise<void>; | ||
export declare type CommandErrorFunction = (context: Context, terminal: Terminal, nextFunction: NextFunctionError, error: Error) => void; | ||
export type NextFunctionError = (error?: Error) => void; | ||
export type NextFunctionSuccess = () => void; | ||
export type NextFunction = NextFunctionSuccess | NextFunctionError; | ||
export type CommandFunction = (context: Context, terminal: Terminal, nextFunction: NextFunction) => void | Promise<void>; | ||
export type CommandErrorFunction = (context: Context, terminal: Terminal, nextFunction: NextFunctionError, error: Error) => void; | ||
export interface OptionsLayer { | ||
@@ -39,5 +39,7 @@ subCommands: string[]; | ||
handleError?: CommandErrorFunction; | ||
private command; | ||
private notInCommand; | ||
private baseMathSetting; | ||
command: string; | ||
notInCommand: string[]; | ||
baseMathSetting: { | ||
isRoot: boolean; | ||
}; | ||
isRouter: boolean; | ||
@@ -44,0 +46,0 @@ route?: IRoute; |
@@ -55,2 +55,3 @@ "use strict"; | ||
const next = (error) => { | ||
var _a; | ||
if (error) | ||
@@ -64,3 +65,3 @@ console.log(error); | ||
layerStack = this.stack[index]; | ||
match = layerStack.match(this.params.command); | ||
match = layerStack.match(this.params.command || ''); | ||
index++; | ||
@@ -80,3 +81,3 @@ if (!match) { | ||
}; | ||
layerStack.route.start(this.session, internalParams); | ||
(_a = layerStack.route) === null || _a === void 0 ? void 0 : _a.start(this.session, internalParams); | ||
} | ||
@@ -86,3 +87,4 @@ if (error && layerStack.handleError) { | ||
} | ||
layerStack.handle({ session: this.session, params: this.params }, Terminal_1.terminal, next); | ||
if (layerStack.handle) | ||
layerStack.handle({ session: this.session, params: this.params }, Terminal_1.terminal, next); | ||
return; | ||
@@ -89,0 +91,0 @@ } |
export interface OptionsAsk { | ||
hidden: boolean; | ||
} | ||
declare const ask: (question: string, optionsAsk?: OptionsAsk | undefined) => Promise<string>; | ||
declare const ask: (question: string, optionsAsk?: OptionsAsk) => Promise<string>; | ||
export { ask }; |
{ | ||
"name": "cowmand", | ||
"version": "0.6.1", | ||
"version": "0.6.2", | ||
"description": "Fast helper to create a cli", | ||
@@ -5,0 +5,0 @@ "tags": [ |
![Cowmand][cowmand-logo] | ||
# _🐮 Cowmand - _BETA_ | ||
# _🐮 Cowmand - \_BETA_ | ||
## Introduction | ||
This lib get beginning of express to create a cli. It's a simple way to create a cli. | ||
## Installation | ||
@@ -14,9 +15,11 @@ | ||
Use npm: | ||
``` | ||
$ npm install cowmmand | ||
$ npm install cowmand | ||
``` | ||
Use yarn: | ||
``` | ||
$ yarn add cowmmand | ||
$ yarn add cowmand | ||
``` | ||
@@ -26,4 +29,4 @@ | ||
Using middleware in global, but with rules to notIn `["login"]`. | ||
Using middleware in global, but with rules to notIn `["login"]`. | ||
```typescript | ||
@@ -41,5 +44,3 @@ import Cowmand from 'cowmand'; | ||
program.command(['me'], (context, terminal) => { | ||
terminal | ||
.log(`Hello, ${context.session.user?.name}!`) | ||
.end(); | ||
terminal.log(`Hello, ${context.session.user?.name}!`).end(); | ||
}); | ||
@@ -50,4 +51,4 @@ | ||
Using middleware before command handle: | ||
Using middleware before command handle: | ||
```typescript | ||
@@ -63,5 +64,3 @@ import Cowmand from 'cowmand'; | ||
program.command(['me'], GuardLogin, (context, terminal) => { | ||
terminal | ||
.log(`Hello, ${context.session.user?.name}!`) | ||
.end(); | ||
terminal.log(`Hello, ${context.session.user?.name}!`).end(); | ||
}); | ||
@@ -73,4 +72,5 @@ | ||
## Docs | ||
**Terminal** [Docs](/docs/Terminal.md) | ||
**Terminal** [Docs](/docs/Terminal.md) | ||
## New Features | ||
@@ -84,8 +84,10 @@ | ||
**** | ||
--- | ||
This project is under the MIT license. See the [LICENSE][license-link] file for more details. | ||
<!-- Markdown link & img's --> | ||
[license-link]: /LICENSE | ||
[cowmand-logo]: https://i.imgur.com/dWPzX9W.png | ||
[cowmand-npm]: https://www.npmjs.com/package/cowmmand | ||
[cowmand-npm]: https://www.npmjs.com/package/cowmand |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
115229
26
726
87
0