1.4.5 • Published 2 years ago
cmdy v1.4.5
cmdy
table of contents
about
"cmdy" is a node js cmd argument framework that looks like the docker cli tool.
Features
General
- root and sub commands
- differend cmd callbacks
- state and value flags
cmd (sub cmd)
- own flags
- global gflas
- premade or custom help function/generator
- cmd groups
flags
- value flags with types
- default values
- aliases
- shorthand
Getting started
1. Install package
npm i cmdy
2. Add example code
import { Flag, parseCmd, CmdDefinition } from "../src/index"
const force: Flag = {
name: "force",
description: "The force flag",
}
const port: Flag = {
name: "port",
description: "The port flag",
shorthand: "p",
types: ["number"]
}
const verbose: Flag = {
name: "verbose",
description: "The verbose flag",
shorthand: "V",
}
const version: Flag = {
name: "version",
description: "The verbose flag",
alias: ["v", "ve", "ver", "vers", "versi", "versio"],
shorthand: "v",
}
const ps: CmdDefinition = {
name: "ps",
description: "The ps command",
flags: [
port
],
allowUnknownArgs: true,
exe: async (res) => console.log("ps: ", res.cmd.name + "\nres-data:\n", res.flags, res.valueFlags)
}
const start: CmdDefinition = {
name: "start",
description: "The start command",
flags: [
port
],
exe: async (res) => console.log("start: ", res.cmd.name + "\nres-data:\n", res.flags, res.valueFlags)
}
const stop: CmdDefinition = {
name: "stop",
description: "The stop command",
flags: [
force
],
exe: async (res) => console.log("stop: ", res.cmd.name + "\nres-data:\n", res.flags, res.valueFlags)
}
const root: CmdDefinition = {
name: "testcmd",
description: "The root testcmd command",
cmds: [
start,
stop,
ps,
],
flags: [
version
],
//exe: async () => console.log("asdasdd")
}
parseCmd({
cmd: root,
globalFlags: [
verbose
]
}).exe()
npm scripts
The npm scripts are made for linux but can also work on mac and windows.
use
You can run npm scripts in the project folder like this:
npm run <scriptname>
Here is an example:
npm run test
base scripts
You can find all npm scripts in the package.json
file.
This is a list of the most important npm scripts:
- test // test the app
- build // build the app
- exec // run the app
- start // build and run the app
watch mode
Like this example you can run all npm scripts in watch mode:
npm run start:watch
contribution
- fork the project
- implement your idea
- create a pull/merge request
// please create seperated forks for different kind of featues/ideas/structure changes/implementations
cya ;3
by majo418
1.4.5
2 years ago
1.4.4
2 years ago
1.4.2
2 years ago
1.3.6
2 years ago
1.3.5
2 years ago
1.2.6
2 years ago
1.4.1
2 years ago
1.3.2
2 years ago
1.4.0
2 years ago
1.3.1
2 years ago
1.2.5
2 years ago
1.2.4
2 years ago
1.2.2
2 years ago
1.2.1
2 years ago
1.1.8
2 years ago
1.1.5
2 years ago
1.1.3
2 years ago
1.0.3
2 years ago
1.0.0
2 years ago