Comparing version
@@ -0,0 +0,0 @@ import "colors"; |
@@ -35,3 +35,3 @@ "use strict"; | ||
this.commandExecuted = true; | ||
const args = bargs_1.bargs(command.argDefinitions, process.argv.slice(3)); | ||
const args = (0, bargs_1.bargs)(command.argDefinitions, process.argv.slice(3)); | ||
const outputArgs = {}; | ||
@@ -38,0 +38,0 @@ if (args.help || args._unknown.help || args.h || args._unknown.h) |
@@ -10,3 +10,3 @@ { | ||
"name": "daph", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "✨ A simple CLI commander system", | ||
@@ -40,11 +40,10 @@ "repository": { | ||
"@types/colors": "^1.2.1", | ||
"@types/node": "^14.0.27", | ||
"@types/node": "^18.0.6", | ||
"rimraf": "^3.0.2", | ||
"ts-node": "^9.0.0", | ||
"typescript": "^3.9.7" | ||
"typescript": "^4.7.4" | ||
}, | ||
"dependencies": { | ||
"bargs": "^1.0.1", | ||
"bargs": "^1.0.4", | ||
"colors": "^1.4.0" | ||
} | ||
} |
# 🦄 Daph | ||
- A simple CLI commander system ✨ | ||
- A simple CLI commander system ✨ | ||
# 📥 Installation | ||
Using yarn: | ||
``` | ||
$ yarn add daph | ||
``` | ||
Using npm: | ||
``` | ||
@@ -15,2 +20,3 @@ $ npm install daph | ||
# 🔧 Usage | ||
```ts | ||
@@ -22,3 +28,5 @@ daph | ||
``` | ||
- `ICommand`: Where command is defined to be used when separating arguments. Structure: | ||
- `ICommand`: Where command is defined to be used when separating arguments. Structure: | ||
```js | ||
@@ -37,3 +45,5 @@ { | ||
``` | ||
- `ArgDefinition`: Where options are defined to be used when separating arguments. Structure: | ||
- `ArgDefinition`: Where options are defined to be used when separating arguments. Structure: | ||
```js | ||
@@ -48,11 +58,13 @@ { | ||
``` | ||
- `callback(commandName, args) => unknown`: If the command you set is used, the action to be applied. Example: | ||
- `callback(commandName, args) => unknown`: If the command you set is used, the action to be applied. Example: | ||
```js | ||
daph // callback(commandName, args) ⬇️ | ||
.createCommand(ICommand, (commandName, args) => { | ||
console.log("You used", commandName, "command with arguments", args); | ||
}); | ||
daph.createCommand(ICommand, (commandName, args) => { // callback(commandName, args) ⬇️ | ||
console.log("You used", commandName, "command with arguments", args); | ||
}); | ||
``` | ||
# 🛠️ Example | ||
```js | ||
@@ -81,2 +93,3 @@ import daph from "daph"; | ||
# 🔗 Contributing / Issues / Ideas | ||
Feel free to use GitHub's features ✨ |
@@ -30,6 +30,3 @@ import { bargs } from "bargs"; | ||
export type DaphFunction = ( | ||
command: string, | ||
args: UnknownObject, | ||
) => unknown; | ||
export type DaphFunction = (command: string, args: UnknownObject) => unknown; | ||
@@ -85,3 +82,4 @@ export type ArgDefinition = { | ||
for (const definition of command.argDefinitions) { | ||
if (!definition.isOptional && !args[definition.name]) return this.handleHelp(command); | ||
if (!definition.isOptional && !args[definition.name]) | ||
return this.handleHelp(command); | ||
outputArgs[definition.name] = args[definition.name]; | ||
@@ -88,0 +86,0 @@ } |
{ | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"declaration": true, | ||
"removeComments": true, | ||
"allowSyntheticDefaultImports": true, | ||
"target": "es2017", | ||
"sourceMap": true, | ||
"outDir": "./dist", | ||
"baseUrl": "./", | ||
"incremental": true, | ||
"skipLibCheck": true, | ||
"typeRoots": [ | ||
"node_modules/@types", | ||
"@types" | ||
] | ||
"module": "commonjs", | ||
"declaration": true, | ||
"removeComments": true, | ||
"allowSyntheticDefaultImports": true, | ||
"target": "es2017", | ||
"sourceMap": true, | ||
"outDir": "./dist", | ||
"baseUrl": "./", | ||
"incremental": true, | ||
"skipLibCheck": true, | ||
"typeRoots": ["node_modules/@types", "@types"] | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
4
-20%91
16.67%66605
-28.76%232
-2.11%Updated