You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Supporting multiple commands as multiple functions
Curious how you'd think about structuring this? Something like this?
/** * top-level help here */module.exports={/** * one command's help */commandA: function(a,b,c){ ... },/** * another command's help */commandB: function(a,b,c){ ... }}
Am I correct that it is important that you bring a function to zeroarg, in order to take advantage of function.toString() as the documentation source?
That is, would it need to look like:
module.exports=zeroarg(function(){return{/** * one command's help */commandA: function(a,b,c){ ... },/** * another command's help */commandB: function(a,b,c){ ... }};});
Maybe I just didn't quite understand this:
And zeroarg would know if the module was not the entry point and just be an identity function if not.
It does look like yargs has support for sub-command nesting, at least via the .commandDir() method. But I'm not sure that'll work for what's going on here.
Activity
tmcw commentedon May 9, 2017
Hey Ryan!
Yeah! Within the current setup, it'd be a little more like
And zeroarg would know if the module was not the entry point and just be an identity function if not.
sub-sub commands... yes if supported by the backend, but afaik yargs doesn't support command nesting, and if commander does, I'm misreading the docs.
rclark commentedon May 9, 2017
Am I correct that it is important that you bring a function to zeroarg, in order to take advantage of
function.toString()as the documentation source?That is, would it need to look like:
Maybe I just didn't quite understand this:
It does look like yargs has support for sub-command nesting, at least via the
.commandDir()method. But I'm not sure that'll work for what's going on here.