As a newcomer to developing CLI apps, I've chosen to work with ts-node and commander. However, I'm currently facing a challenge in understanding how to access the options that users pass into my command action.
program
.version(version)
.name(name)
.option('-sm, --something', 'does something', false)
.description(description);
program.command('clear-environment').action(() => {
/// Seeking ways to view the user-passed usage options here
if (options.contains('-sm')) {
// perform certain actions
}
(async () => {
const userFeedback = await getPromptAnswers(CLEAR_ENV_QUESTIONS);
if (userFeedback?.deleteAll) {
cleanEnvironment();
}
})();
});
I'm uncertain if this approach is correct, so any advice or guidance on this matter would be greatly appreciated.