vvakame / commandpost Goto Github PK
View Code? Open in Web Editor NEWcommand line option parser for Node.js
License: MIT License
command line option parser for Node.js
License: MIT License
In the fly
CLI, we have a command named test
(like fly test
).
We also have a "global" option to specify and environment -e, --env <value>
.
The issue is if you do fly -e test other_command
, commandpost thinks test
is the command, not the value of the env
option.
I have been hard-pressed to get the text passed into description to display:
let root = commandpost
.create<any, any>("")
.version(this.pkg.version, "-v, --version")
.description("This is a fancy program that does neat things.");
// ...
commandpost
.exec(root, this.process.argv);
Am I doing something wrong? Thanks!
I'd like to do some parsing of a string option before it gets to my runner method. Right now, this requires that I create an interface to accept the string list, then a second interface to hold the parsed result. I'd like some way of passing a function to mapper with the signature (values: string[]) => T
, and have that function called before the action
is invoked.
I am getting the following error:
TypeScript error: node_modules/commandpost/index.d.ts(1,15): Error TS2307: Cannot find module './lib'.
When compiling a project that has indirect dependencies on commandpost
. Is it possible to express this path in a different way? I am not sure it is a commandpost
issue, but I have no idea of how to get rid of it otherwise.
Is there any way to receive commands in any order? For example, it would be nice to be able to do something like this:
$ node index.js --port 1234 server --uglify -inspect
Currently only this works:
$ node index.js server --port 1234 --uglify --inspect
Commandpost doesn't allow the user to pass a root option AFTER the subcommand.
For example, if I have a root option --user
and a subcommand download
, then it needs to be passed like this:
$ myapp --user me download # Works
But it would be great if the user could do this instead:
$ myapp download --user me # Currently Fails
It seems fairly common to allow the command to come first (like in git and commander). Could you please allow this in commandpost too?
Is it possible to setup a callback for missing required parameters? Right now, it shows a stack trace, by default. I would have to catch and parse the error message if I wanted something custom, right?
If this doesn't exist, my hope would be for something like this:
let newTemp = root
.subCommand<INewCmdOpts, INewCmdArgs>("new <item>")
.description("Generate a thing from an item.")
.option("-n, --name <name>", "a description")
.optionError((oName, errType, defaultMsg): string => customMessageIfAny)
.commandError((cName, errType, defaultMsg): string => customMessageIfAny);
Thanks in advance.
Could you please expose the Command (and any other publicly-usable model) to import? I wouldn't mind something like this:
import * as cp from 'commandpost';
setupOneCmd(): cp.Command {
// make and return a cp.Command
}
Thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.