-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Description
Hi I'm trying to create a cli app (interactive) that uses commands to perform tasks. For each task I create a command instance.
For example I provide a get command for user to use.
const getCmd = program.command('get')
.description('get information from a endpoint')
.argument('<path>', 'path of the component, [endpointName/componentType]')
.argument('[compName]', 'name of the component', '')
.option('-a, --attributes [attributeNames...]', 'get attributes from component', '')
.action(async (path, compName, options, cmd) => {
...
});
In the interactive shell (I use readline lib) if user input get args opts the getCmd will called
getCmd.parseAsync(allargs [])
then after the command is executed, the shell waiting for next command, if user inputs the same get command but with some options removed, when it calls the getCmd.parseAsync(allargs) again I found some of the options from the first execution remains.
So basically I assume each time I have to create a new instance of the get command. I wonder if there is a way to reset the command for reuse?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels