-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Aguments and Options together? #989
Comments
You can add flags to commands.
|
Sorry, closed by accident. It does not quite resolve what I'm after. Looking to have the # current solution does this
ng generate component <pathToDirectory>
# but not this
ng generate component [options] <pathToDirectory> |
After reading this about multiline cli's, it looks like the path of least resistance is to use commander to trigger another command program using the current one. So Have you seen this done before? Would there be a better way? Thank you for getting back to me so promptly before, I appreciate it. |
I'll give you a scatter of relevant information.
(without the
|
I think that maybe I'm after something a bit more customizable. It doesn't seem this or any other CLI tool that supports typescript properly exists to handle this easily. In example, i'd probably want an API that is a little more declarative: import { Command } from 'commander'
const program = new Command()
.command('generate')
.command('component')
.options('flags', (option) => {
option.add('-c', '--class', 'creates a class')
option.add('-f', '--function', 'creates a function')
})
.parse(process.argv) This way I know exactly what the user could input and in what order. I find the options in commander being at the start restrictive. Thank you for your help again and apologies this doesn't support the mission of team Commander. |
Support for nested commands got added in Commander v5.0.0. |
Hi Guys,
How do we provide flags for aguments? i don't mind what parts of the API to get there, I just want to get there. I read through the readme and the arguments section was the closest thing I could find.
In a CLI, it would be like @angular/cli
Where
options
are options flags, such as-c
or-f
.What is best practice? Can options be added using
.options
into the arguments?The text was updated successfully, but these errors were encountered: