Skip to content

Commit c47b4d5

Browse files
tsondergaardThomas Sondergaard
authored and
Thomas Sondergaard
committed
argparse: Add required: boolean to SubparserOptions
The required option was added in python 3.7.0a2 as a way to make subparsers required again (the default behaviour in Python 2.7). * https://bugs.python.org/issue9253 * python/cpython#3027 Since npm argparse 2.0.1 is a straight conversion of the Python 3.9.0rc1 version of argparse the required flag is valid here too.
1 parent 46c3dc0 commit c47b4d5

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

types/argparse/argparse-tests.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ const subparserExample = new ArgumentParser({
179179
const subparsers = subparserExample.add_subparsers({
180180
title: "subcommands",
181181
dest: "subcommand_name",
182+
required: true,
182183
});
183184

184185
let bar = subparsers.add_parser("c1", { add_help: true, help: "c1 help" });

types/argparse/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ export interface SubparserOptions {
5151
dest?: string;
5252
help?: string;
5353
metavar?: string;
54+
required?: boolean;
5455
}
5556

5657
export interface SubArgumentParserOptions extends ArgumentParserOptions {

0 commit comments

Comments
 (0)