-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathcommand-line-arguments.ts
64 lines (62 loc) · 1.79 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import yargs from 'yargs/yargs';
import { hideBin } from 'yargs/helpers';
export type CommandLineArguments = {
projectDirectory: string;
tempDirectory: string | undefined;
reset: boolean;
backport: boolean;
defaultBranch: string;
fetchRemote: 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,
})
.option('backport', {
describe:
'Instructs the tool to bump the second part of the version rather than the first for a backport release.',
type: 'boolean',
default: false,
})
.option('default-branch', {
alias: 'b',
describe: 'The name of the default branch in the repository.',
default: 'main',
type: 'string',
})
.option('fetch-remote', {
alias: 'f',
describe: 'Syncronizes local git references with remote',
default: true,
type: 'boolean',
})
.help()
.strict()
.parse();
}