-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathcommand-line-arguments.ts
43 lines (41 loc) · 1.19 KB
/
command-line-arguments.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import yargs from 'yargs/yargs';
import { hideBin } from 'yargs/helpers';
export type CommandLineArguments = {
projectDirectory: string;
tempDirectory: string | undefined;
reset: boolean;
};
/**
* Parses the arguments provided on the command line using `yargs`.
*
* @param argv - The name of this executable and its arguments (as obtained via
* `process.argv`).
* @returns A promise for the `yargs` arguments object.
*/
export async function readCommandLineArguments(
argv: string[],
): Promise<CommandLineArguments> {
return await yargs(hideBin(argv))
.usage(
'This tool prepares your project for a new release by bumping versions and updating changelogs.',
)
.option('project-directory', {
alias: 'd',
describe: 'The directory that holds your project.',
default: '.',
})
.option('temp-directory', {
describe:
'The directory that is used to hold temporary files, such as the release spec template.',
type: 'string',
})
.option('reset', {
describe:
'Removes any cached files from a previous run that may have been created.',
type: 'boolean',
default: false,
})
.help()
.strict()
.parse();
}