In the previous article, we logged the program variable and saw some json. In this article, let’s understand how to access an option value passed, specifically program.resetPreferences
Let’s modify the log to print program.resetPreferences
Access options passed in CLI:
- Add the following as your first line in run():
console.log("program.resetPreferences:", program.resetPreferences);
- Build the create-next-app
npm run build
- Run the following command
npx create-my-app --reset-preferences
You pass –reset-preferences option to the cli
Conclusion:
So, to find out if any of the options you configured using Commander are passed in the CLI, you can access the flag using camelCase.
Example:
program.useNpm
program.usePnpm
program.resetPreferences
I am building a platform that explains best practices used in open source by elite programmers.
Join the waitlist and I will send you the link to the tutorials once they are ready.
If you have any questions, feel free to reach out to me at ramu.narasinga@gmail.com
Get free courses inspired by the best practices used in open source.
About me:
Website: https://ramunarasinga.com/
Linkedin: https://www.linkedin.com/in/ramu-narasinga-189361128/
Github: https://github.com/Ramu-Narasinga
Email: ramu.narasinga@gmail.com
Top comments (0)