Open jasonkuhrt opened 4 years ago
Developing an API for the tree. I find the POJO awkward, the keys ambiguous in meaning given commands co-locate their names.
cmd
instead of command
cmd.group
varg func that accepts multiple commandscli
just a special instance of cmd.group
that permits not having a parent (because its root)buildCLI
to just cli
, var ident should be name of cli e.g. const santa = cli(...)
const a = cmd('a').add(param.string('febe').optional()) //...
const b = cmd('b').runs(args => {
args.febe // undefined | string
})
- buildCLI({
- a: {
- b,
- $default: a
- }
- })
+ cli(
+ a.group(b)
+ )
- buildCLI({
- a,
- b: {
- b1,
- b2,
- b3,
- $default: b2
- },
- c,
- })
+ cli(
+ a,
+ b.group(
+ b1,
+ b2,
+ b3,
+ ),
+ c,
+ )
+
+ statics approach (we can support both static+chaining)
+
+ cli(
+ a,
+ cmd.group(b)(
+ b1,
+ b2,
+ b3,
+ )
+ c,
+ )
+
Proposal:
Goals
npm
/yarn
hub
seamlessly extendsgit
)How the api might look like:
A combinator api manifested as chaining. Under the hood all this is doing is building up a plain javascript object. This makes snapshot testing and debugging super easy. Also opens up the potential for powerful plugins.
param statics might turn out to need context. Not sure yet. If so, that might manifest like so:
Commands could be brought together around a "routing tree":
Example use:
An important feature would be how ancestor commands contribute params to descendent commands. Example:
...
more to come!
Ecosystem:
oclif
problems:
yargs
problems:
commander
problems: