Comments (9)
You mean in addition to vorpal.parse
? I suppose I could literally map it to minimist if that helps.
from vorpal.
That's the idea, you'd map to minimist by default, with an optional second argument that'd run commander.js parse -- which would use your vorpal command list to return an object. Both are meant to be maps over to minimist/commander just in case it's needed.
Related to using this: on vorpal.parse -- how do I detect whether or not a command was found? Is there a default callback, like parse(argv, notFoundFn)?
from vorpal.
It is meant to do exactly what you app does if you run it first. So it would technically display the help command.
Check out the .catch
command (it's new, maybe I didn't document it yet): here's an example I pulled out of wat
, which im working on:
vorpal
.catch('[commands...]')
.option('-d, --detail', 'View detailed markdown on item.')
.option('-i, --install', 'View installation instructions.')
.autocompletion(function (text, iteration, cb) {
const self = this;
const index = parent.clerk.indexer.index();
let result = util.autocomplete(text, iteration, index, function (word, options) {
const res = self.match(word, options);
return res;
});
if (_.isArray(result)) {
result.sort();
}
cb(undefined, result);
})
.action(function (args, cb) {
const self = this;
args = args || {};
args.options = args.options || {};
// Handle humans.
if (String(args.commands[0]).toLowerCase() === 'wat') {
args.commands.shift();
}
// ...
cb();
});
Catch basically is called if you don't match on any other command, so it overrides help as the default function if no command is met. By adding in a [variadicArg...]
, you can pretty much do anything you want.
from vorpal.
On the parse, I think im gonna do this:
var args = vorpal.parse(process.argv, { use: 'minimist' });
var args = vorpal.parse(process.argv, { use: 'commander' });
from vorpal.
I like it.
from vorpal.
:)
Does the catch thing make sense?
from vorpal.
Yes, it makes sense, does just what I want.
from vorpal.
Perfect.
from vorpal.
@Downchuck Added this. Coming out in a release today.
from vorpal.
Related Issues (20)
- Wait for promise
- Current project status HOT 7
- Compatibility with Node v11 HOT 1
- Support for default values dropped ?
- Vorpal + Vim ? An ability to launch interactive cli app from the vorpal app
- command.log like console.table()
- access raw unparsed command ? HOT 1
- Complex inputs renders weird stuff to the screen HOT 1
- Run script of my vorpal commands does not work on async functions HOT 2
- How to make sub commands without the multi-word command feature?
- vi command edit mode, aka set -o vi
- Results of running example code is different from example. The Version is 1.12.0 HOT 1
- types for localstorage wrong HOT 1
- Plural forms, shortened words or alternatives in the command string.
- Arguments with `=` (equals sign) in them are parsed incorrectly HOT 2
- New vulnerabilities in used old dependencies: inquirer & lodash HOT 5
- How to auto restart vorpal after any change to source code?
- Deno support? HOT 2
- can I override the exit command?
- command.after seems to do nothing HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vorpal.