Skip to content

Commit 70b970f

Browse files
authored
chore: import CLI help text (#411)
* chore: import CLI help text * update
1 parent d4631e9 commit 70b970f

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

packages/cli/src/index.ts

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,10 @@ const checkAction = async (options: Parameters<typeof actions.check>[0]): Promis
3131
};
3232

3333
function createProgram() {
34-
const program = new Command('zen');
35-
36-
program.version(getVersion()!, '-v --version', 'display CLI version');
34+
const program = new Command('zen')
35+
.alias('zenstack')
36+
.helpOption('-h, --help', 'Show this help message')
37+
.version(getVersion()!, '-v --version', 'Show CLI version');
3738

3839
const schemaExtensions = ZModelLanguageMetaData.fileExtensions.join(', ');
3940

@@ -55,7 +56,7 @@ function createProgram() {
5556

5657
program
5758
.command('generate')
58-
.description('Run code generation plugins.')
59+
.description('Run code generation plugins')
5960
.addOption(schemaOption)
6061
.addOption(noVersionCheckOption)
6162
.addOption(new Option('-o, --output <path>', 'default output directory for code generation'))
@@ -74,7 +75,7 @@ function createProgram() {
7475
.addOption(new Option('-n, --name <name>', 'migration name'))
7576
.addOption(new Option('--create-only', 'only create migration, do not apply'))
7677
.addOption(migrationsOption)
77-
.description('Create a migration from changes in schema and apply it to the database.')
78+
.description('Create a migration from changes in schema and apply it to the database')
7879
.action((options) => migrateAction('dev', options));
7980

8081
migrateCommand
@@ -83,23 +84,23 @@ function createProgram() {
8384
.addOption(new Option('--force', 'skip the confirmation prompt'))
8485
.addOption(migrationsOption)
8586
.addOption(noVersionCheckOption)
86-
.description('Reset your database and apply all migrations, all data will be lost.')
87+
.description('Reset your database and apply all migrations, all data will be lost')
8788
.action((options) => migrateAction('reset', options));
8889

8990
migrateCommand
9091
.command('deploy')
9192
.addOption(schemaOption)
9293
.addOption(noVersionCheckOption)
9394
.addOption(migrationsOption)
94-
.description('Deploy your pending migrations to your production/staging database.')
95+
.description('Deploy your pending migrations to your production/staging database')
9596
.action((options) => migrateAction('deploy', options));
9697

9798
migrateCommand
9899
.command('status')
99100
.addOption(schemaOption)
100101
.addOption(noVersionCheckOption)
101102
.addOption(migrationsOption)
102-
.description('Check the status of your database migrations.')
103+
.description('Check the status of your database migrations')
103104
.action((options) => migrateAction('status', options));
104105

105106
migrateCommand
@@ -109,14 +110,14 @@ function createProgram() {
109110
.addOption(migrationsOption)
110111
.addOption(new Option('--applied <migration>', 'record a specific migration as applied'))
111112
.addOption(new Option('--rolled-back <migration>', 'record a specific migration as rolled back'))
112-
.description('Resolve issues with database migrations in deployment databases.')
113+
.description('Resolve issues with database migrations in deployment databases')
113114
.action((options) => migrateAction('resolve', options));
114115

115-
const dbCommand = program.command('db').description('Manage your database schema during development.');
116+
const dbCommand = program.command('db').description('Manage your database schema during development');
116117

117118
dbCommand
118119
.command('push')
119-
.description('Push the state from your schema to your database.')
120+
.description('Push the state from your schema to your database')
120121
.addOption(schemaOption)
121122
.addOption(noVersionCheckOption)
122123
.addOption(new Option('--accept-data-loss', 'ignore data loss warnings'))
@@ -125,25 +126,27 @@ function createProgram() {
125126

126127
program
127128
.command('info')
128-
.description('Get information of installed ZenStack packages.')
129+
.description('Get information of installed ZenStack packages')
129130
.argument('[path]', 'project path', '.')
130131
.addOption(noVersionCheckOption)
131132
.action(infoAction);
132133

133134
program
134135
.command('init')
135-
.description('Initialize an existing project for ZenStack.')
136+
.description('Initialize an existing project for ZenStack')
136137
.argument('[path]', 'project path', '.')
137138
.addOption(noVersionCheckOption)
138139
.action(initAction);
139140

140141
program
141142
.command('check')
142-
.description('Check a ZModel schema for syntax or semantic errors.')
143+
.description('Check a ZModel schema for syntax or semantic errors')
143144
.addOption(schemaOption)
144145
.addOption(noVersionCheckOption)
145146
.action(checkAction);
146147

148+
program.addHelpCommand('help [command]', 'Display help for a command');
149+
147150
program.hook('preAction', async (_thisCommand, actionCommand) => {
148151
if (actionCommand.getOptionValue('versionCheck') !== false) {
149152
await checkNewVersion();

0 commit comments

Comments
 (0)