@@ -59,110 +59,117 @@ export abstract class CommandLineParameterProvider {
5959 }
6060
6161 /**
62- * Defines a command-line switch whose boolean value is true if the switch is provided,
63- * and false otherwise .
62+ * Defines a command-line parameter whose value must be a string from a fixed set of
63+ * allowable choices (similar to an enum) .
6464 *
6565 * @remarks
66- * Example: example-tool --debug
66+ * Example: example-tool --log-level warn
6767 */
68- public defineFlagParameter ( definition : ICommandLineFlagDefinition ) : CommandLineFlagParameter {
69- const parameter : CommandLineFlagParameter = new CommandLineFlagParameter ( definition ) ;
68+ public defineChoiceParameter ( definition : ICommandLineChoiceDefinition ) : CommandLineChoiceParameter {
69+ const parameter : CommandLineChoiceParameter = new CommandLineChoiceParameter ( definition ) ;
7070 this . _defineParameter ( parameter ) ;
7171 return parameter ;
7272 }
7373
7474 /**
75- * Returns the CommandLineFlagParameter with the specified long name.
75+ * Returns the CommandLineChoiceParameter with the specified long name.
7676 * @remarks
7777 * This method throws an exception if the parameter is not defined.
7878 */
79- public getFlagParameter ( parameterLongName : string ) : CommandLineFlagParameter {
80- return this . _getFlagParameter ( parameterLongName , CommandLineParameterKind . Flag ) ;
79+ public getChoiceParameter ( parameterLongName : string ) : CommandLineChoiceParameter {
80+ return this . _getFlagParameter ( parameterLongName , CommandLineParameterKind . Choice ) ;
8181 }
8282
8383 /**
84- * Defines a command-line parameter whose value is a single text string.
84+ * Defines a command-line switch whose boolean value is true if the switch is provided,
85+ * and false otherwise.
8586 *
8687 * @remarks
87- * Example: example-tool --message "Hello, world!"
88+ * Example: example-tool --debug
8889 */
89- public defineStringParameter ( definition : ICommandLineStringDefinition ) : CommandLineStringParameter {
90- const parameter : CommandLineStringParameter = new CommandLineStringParameter ( definition ) ;
90+ public defineFlagParameter ( definition : ICommandLineFlagDefinition ) : CommandLineFlagParameter {
91+ const parameter : CommandLineFlagParameter = new CommandLineFlagParameter ( definition ) ;
9192 this . _defineParameter ( parameter ) ;
9293 return parameter ;
9394 }
9495
9596 /**
96- * Returns the CommandLineStringParameter with the specified long name.
97+ * Returns the CommandLineFlagParameter with the specified long name.
9798 * @remarks
9899 * This method throws an exception if the parameter is not defined.
99100 */
100- public getStringParameter ( parameterLongName : string ) : CommandLineStringParameter {
101- return this . _getFlagParameter ( parameterLongName , CommandLineParameterKind . String ) ;
101+ public getFlagParameter ( parameterLongName : string ) : CommandLineFlagParameter {
102+ return this . _getFlagParameter ( parameterLongName , CommandLineParameterKind . Flag ) ;
102103 }
103104
104105 /**
105- * Defines a command-line parameter whose value is one or more text strings .
106+ * Defines a command-line parameter whose value is an integer .
106107 *
107108 * @remarks
108- * Example: example-tool --add file1.txt --add file2.txt --add file3.txt
109+ * Example: example-tool l --max-attempts 5
109110 */
110- public defineStringListParameter ( definition : ICommandLineStringListDefinition ) : CommandLineStringListParameter {
111- const parameter : CommandLineStringListParameter = new CommandLineStringListParameter ( definition ) ;
111+ public defineIntegerParameter ( definition : ICommandLineIntegerDefinition ) : CommandLineIntegerParameter {
112+ const parameter : CommandLineIntegerParameter = new CommandLineIntegerParameter ( definition ) ;
112113 this . _defineParameter ( parameter ) ;
113114 return parameter ;
114115 }
115116
116117 /**
117- * Returns the CommandLineStringListParameter with the specified long name.
118+ * Returns the CommandLineIntegerParameter with the specified long name.
118119 * @remarks
119120 * This method throws an exception if the parameter is not defined.
120121 */
121- public getStringListParameter ( parameterLongName : string ) : CommandLineStringListParameter {
122- return this . _getFlagParameter ( parameterLongName , CommandLineParameterKind . StringList ) ;
122+ public getIntegerParameter ( parameterLongName : string ) : CommandLineIntegerParameter {
123+ return this . _getFlagParameter ( parameterLongName , CommandLineParameterKind . Integer ) ;
123124 }
124125
125126 /**
126- * Defines a command-line parameter whose value is an integer .
127+ * Defines a command-line parameter whose value is a single text string .
127128 *
128129 * @remarks
129- * Example: example-tool l --max-attempts 5
130+ * Example: example-tool --message "Hello, world!"
130131 */
131- public defineIntegerParameter ( definition : ICommandLineIntegerDefinition ) : CommandLineIntegerParameter {
132- const parameter : CommandLineIntegerParameter = new CommandLineIntegerParameter ( definition ) ;
132+ public defineStringParameter ( definition : ICommandLineStringDefinition ) : CommandLineStringParameter {
133+ const parameter : CommandLineStringParameter = new CommandLineStringParameter ( definition ) ;
133134 this . _defineParameter ( parameter ) ;
134135 return parameter ;
135136 }
136137
137138 /**
138- * Returns the CommandLineIntegerParameter with the specified long name.
139+ * Returns the CommandLineStringParameter with the specified long name.
139140 * @remarks
140141 * This method throws an exception if the parameter is not defined.
141142 */
142- public getIntegerParameter ( parameterLongName : string ) : CommandLineIntegerParameter {
143- return this . _getFlagParameter ( parameterLongName , CommandLineParameterKind . Integer ) ;
143+ public getStringParameter ( parameterLongName : string ) : CommandLineStringParameter {
144+ return this . _getFlagParameter ( parameterLongName , CommandLineParameterKind . String ) ;
144145 }
145146
146147 /**
147- * Defines a command-line parameter whose value must be a string from a fixed set of
148- * allowable choices (similar to an enum).
148+ * Defines a command-line parameter whose value is one or more text strings.
149149 *
150150 * @remarks
151- * Example: example-tool --log-level warn
151+ * Example: example-tool --add file1.txt --add file2.txt --add file3.txt
152152 */
153- public defineChoiceParameter ( definition : ICommandLineChoiceDefinition ) : CommandLineChoiceParameter {
154- const parameter : CommandLineChoiceParameter = new CommandLineChoiceParameter ( definition ) ;
153+ public defineStringListParameter ( definition : ICommandLineStringListDefinition ) : CommandLineStringListParameter {
154+ const parameter : CommandLineStringListParameter = new CommandLineStringListParameter ( definition ) ;
155155 this . _defineParameter ( parameter ) ;
156156 return parameter ;
157157 }
158158
159159 /**
160- * Returns the CommandLineChoiceParameter with the specified long name.
160+ * Returns the CommandLineStringListParameter with the specified long name.
161161 * @remarks
162162 * This method throws an exception if the parameter is not defined.
163163 */
164- public getChoiceParameter ( parameterLongName : string ) : CommandLineChoiceParameter {
165- return this . _getFlagParameter ( parameterLongName , CommandLineParameterKind . Choice ) ;
164+ public getStringListParameter ( parameterLongName : string ) : CommandLineStringListParameter {
165+ return this . _getFlagParameter ( parameterLongName , CommandLineParameterKind . StringList ) ;
166+ }
167+
168+ /**
169+ * Generates the command-line help text.
170+ */
171+ public renderHelpText ( ) : string {
172+ return this . _argumentParser . formatHelp ( ) ;
166173 }
167174
168175 /**
@@ -222,12 +229,12 @@ export abstract class CommandLineParameterProvider {
222229 case CommandLineParameterKind . Flag :
223230 argparseOptions . action = 'storeTrue' ;
224231 break ;
225- case CommandLineParameterKind . StringList :
226- argparseOptions . action = 'append' ;
227- break ;
228232 case CommandLineParameterKind . Integer :
229233 argparseOptions . type = 'int' ;
230234 break ;
235+ case CommandLineParameterKind . StringList :
236+ argparseOptions . action = 'append' ;
237+ break ;
231238 }
232239
233240 this . _argumentParser . addArgument ( names , argparseOptions ) ;
0 commit comments