@@ -1731,8 +1731,10 @@ export class Command<
17311731 TFlags ,
17321732 TCommandOptions ,
17331733 Merge < TParentCommandTypes , Merge < TCommandGlobalTypes , TCommandTypes > > ,
1734- undefined extends TConflicts ? TRequired : false ,
1735- TDefaultValue
1734+ TRequired ,
1735+ TDefaultValue ,
1736+ TConflicts ,
1737+ TEnabled
17361738 > ,
17371739 TMappedGlobalOptions extends MapValue <
17381740 TGlobalOptions ,
@@ -1742,6 +1744,7 @@ export class Command<
17421744 TRequired extends OptionOptions [ "required" ] = undefined ,
17431745 TCollect extends OptionOptions [ "collect" ] = undefined ,
17441746 TConflicts extends OptionOptions [ "conflicts" ] = undefined ,
1747+ TEnabled extends OptionOptions [ "enabled" ] = undefined ,
17451748 const TDefaultValue = undefined ,
17461749 TMappedValue = undefined ,
17471750 > (
@@ -1767,6 +1770,7 @@ export class Command<
17671770 defaultText ?: DefaultText < TDefaultValue > ;
17681771 required ?: TRequired ;
17691772 collect ?: TCollect ;
1773+ enabled ?: TEnabled ;
17701774 value ?: OptionValueHandler <
17711775 MapTypes < ValueOf < TGlobalOptions > > ,
17721776 TMappedValue
@@ -1810,8 +1814,10 @@ export class Command<
18101814 TFlags ,
18111815 TCommandOptions ,
18121816 Merge < TParentCommandTypes , Merge < TCommandGlobalTypes , TCommandTypes > > ,
1813- undefined extends TConflicts ? TRequired : false ,
1814- TDefaultValue
1817+ TRequired ,
1818+ TDefaultValue ,
1819+ TConflicts ,
1820+ TEnabled
18151821 > ,
18161822 TMappedGlobalOptions extends MapValue <
18171823 TGlobalOptions ,
@@ -1821,6 +1827,7 @@ export class Command<
18211827 TRequired extends OptionOptions [ "required" ] = undefined ,
18221828 TCollect extends OptionOptions [ "collect" ] = undefined ,
18231829 TConflicts extends OptionOptions [ "conflicts" ] = undefined ,
1830+ TEnabled extends OptionOptions [ "enabled" ] = undefined ,
18241831 const TDefaultValue = undefined ,
18251832 TMappedValue = undefined ,
18261833 > (
@@ -1847,6 +1854,7 @@ export class Command<
18471854 defaultText ?: DefaultText < TDefaultValue > ;
18481855 required ?: TRequired ;
18491856 collect ?: TCollect ;
1857+ enabled ?: TEnabled ;
18501858 value ?: OptionValueHandler <
18511859 MapTypes < ValueOf < TGlobalOptions > > ,
18521860 TMappedValue
@@ -1877,13 +1885,16 @@ export class Command<
18771885 TFlags ,
18781886 TCommandOptions ,
18791887 Merge < TParentCommandTypes , Merge < TCommandGlobalTypes , TCommandTypes > > ,
1880- undefined extends TConflicts ? TRequired : false ,
1881- TDefaultValue
1888+ TRequired ,
1889+ TDefaultValue ,
1890+ TConflicts ,
1891+ TEnabled
18821892 > ,
18831893 TMappedOptions extends MapValue < TOptions , TMappedValue , TCollect > ,
18841894 TRequired extends OptionOptions [ "required" ] = undefined ,
18851895 TCollect extends OptionOptions [ "collect" ] = undefined ,
18861896 TConflicts extends OptionOptions [ "conflicts" ] = undefined ,
1897+ TEnabled extends OptionOptions [ "enabled" ] = undefined ,
18871898 const TDefaultValue = undefined ,
18881899 TMappedValue = undefined ,
18891900 > (
@@ -1910,6 +1921,7 @@ export class Command<
19101921 required ?: TRequired ;
19111922 collect ?: TCollect ;
19121923 conflicts ?: TConflicts ;
1924+ enabled ?: TEnabled ;
19131925 value ?: OptionValueHandler < MapTypes < ValueOf < TOptions > > , TMappedValue > ;
19141926 }
19151927 | OptionValueHandler < MapTypes < ValueOf < TOptions > > , TMappedValue > ,
@@ -1933,14 +1945,20 @@ export class Command<
19331945 opts = { value : opts } ;
19341946 }
19351947
1948+ if ( opts ?. enabled === false ) {
1949+ return this ;
1950+ }
1951+
19361952 const result = splitArguments ( flags ) ;
19371953
19381954 const args : Argument [ ] = result . typeDefinition
19391955 ? parseArgumentsDefinition ( result . typeDefinition )
19401956 : [ ] ;
19411957
1958+ const { enabled : _enabled , ...restOpts } = opts ?? { } ;
1959+
19421960 const option : Option = {
1943- ...opts ,
1961+ ...restOpts ,
19441962 name : "" ,
19451963 description : desc ,
19461964 args,
0 commit comments