MCPcopy
hub / github.com/tj/commander.js / _parseOptionsImplied

Method _parseOptionsImplied

lib/command.js:2008–2037  ·  view source on GitHub ↗

* Apply any implied option values, if option is undefined or default value. * * @private

()

Source from the content-addressed store, hash-verified

2006 * @private
2007 */
2008 _parseOptionsImplied() {
2009 const dualHelper = new DualOptions(this.options);
2010 const hasCustomOptionValue = (optionKey) => {
2011 return (
2012 this.getOptionValue(optionKey) !== undefined &&
2013 !['default', 'implied'].includes(this.getOptionValueSource(optionKey))
2014 );
2015 };
2016 this.options
2017 .filter(
2018 (option) =>
2019 option.implied !== undefined &&
2020 hasCustomOptionValue(option.attributeName()) &&
2021 dualHelper.valueFromOption(
2022 this.getOptionValue(option.attributeName()),
2023 option,
2024 ),
2025 )
2026 .forEach((option) => {
2027 Object.keys(option.implied)
2028 .filter((impliedKey) => !hasCustomOptionValue(impliedKey))
2029 .forEach((impliedKey) => {
2030 this.setOptionValueWithSource(
2031 impliedKey,
2032 option.implied[impliedKey],
2033 'implied',
2034 );
2035 });
2036 });
2037 }
2038
2039 /**
2040 * Argument `name` is missing.

Callers 1

_parseCommandMethod · 0.95

Calls 4

valueFromOptionMethod · 0.95
getOptionValueMethod · 0.95
attributeNameMethod · 0.80

Tested by

no test coverage detected