-
-
Notifications
You must be signed in to change notification settings - Fork 104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[feature] sub commands like 'git remote prune origin' #65
Comments
Only 1-level sub command is currently supported, but I'm interested in this feature, do you know any library that actually supports this? |
Yeah, there are a few CLI tools with subcommands features, but they are all written plain JS:
|
Here's a lazy solution until @egoist figures out how to support this. const app = cac()
app.command('foo bar').action(() => {})
// Parent command (if any) must come after child commands.
app.command('foo').action(() => {}) |
@egoist Would you merge a PR with aleclarson@227835e? |
@aleclarson, required args does not work properly. I guess required options too. const app = cac('git');
app.command('remote add <name>', 'A git remote add.').action((name) => {
console.log('remote add:', name);
});
app
.command('remote rename <a> <b>', 'A git rename `a` to `b`.')
.action((a, b) => {
console.log('remote rename a to b', a, b);
});
app
.command('remote remove', 'Delete something')
.alias(['rm', 'del', 'rmove', 'remoev'])
.action(() => {
console.log('remote remove');
});
app.parse(); Because when checking for required it checks against In the isMatched // if no sub-commands, it will be length 1, as currently
const sub = command.name.split(' ')
const parsedInfo = __assign(__assign({}, parsed), {
args: parsed.args.slice(sub.length)
}); The magic of Open Source 😍 |
No they don't, but I know why that is. Update this.path.every((part, i) => name[i] === part || this.aliasNames.includes(name[i])) example:
Btw, would be good to limit the list of |
@egoist want a PR? I'm sending it soon. |
Issue Type
There doesn't seem to be mention of this, so not sure if possible.
Example:
Maybe this is actually a feature request. I can change it if so.
The text was updated successfully, but these errors were encountered: