Skip to content
This repository was archived by the owner on Jul 6, 2025. It is now read-only.

Commit cdcd83a

Browse files
author
Je
committed
refactor: update cli help messages
1 parent 42d39c2 commit cdcd83a

File tree

6 files changed

+19
-18
lines changed

6 files changed

+19
-18
lines changed

cli.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@ import { listenAndServe, path, ServerRequest, walk } from './std.ts'
55
import util, { existsDirSync, existsFileSync } from './util.ts'
66
import { version } from './version.ts'
77

8-
const commands = ['init', 'dev', 'start', 'build', 'upgrade']
8+
const commands = {
9+
'init': 'Initiate a new aleph app.',
10+
'dev': 'Starts the aleph app in development mode.',
11+
'start': 'Starts the aleph app in production mode.',
12+
'build': 'Builds the aleph app in production mode.',
13+
'upgrade': 'Upgrade the aleph command.'
14+
}
915
const helpMessage = `Aleph.js v${version}
1016
The React Framework in deno.
1117
@@ -16,7 +22,7 @@ Usage:
1622
aleph <command> [...options]
1723
1824
Commands:
19-
${commands.join(', ')}
25+
${Object.entries(commands).map(([name, desc]) => `${name.padEnd(15)}${desc}`).join('\n ')}
2026
2127
Options:
2228
-h, --help Prints help message
@@ -48,6 +54,10 @@ async function main() {
4854
}
4955
}
5056

57+
// get command, default is 'dev'
58+
const hasCommand = args.length > 0 && args[0] in commands
59+
const command = (hasCommand ? String(args.shift()) : 'dev') as keyof typeof commands
60+
5161
// prints aleph.js version
5262
if (argOptions.v) {
5363
console.log(`aleph.js v${version}`)
@@ -65,11 +75,10 @@ async function main() {
6575
}
6676

6777
// prints help message
68-
const hasCommand = args.length > 0 && commands.includes(args[0])
6978
if (argOptions.h || argOptions.help) {
7079
if (hasCommand) {
71-
import(`./cli/${args.shift()}.ts`).then(({ helpMessage }) => {
72-
console.log(`Aleph.js v${version}`)
80+
import(`./cli/${command}.ts`).then(({ helpMessage }) => {
81+
console.log(commands[command])
7382
if (util.isNEString(helpMessage)) {
7483
console.log(helpMessage)
7584
}
@@ -105,9 +114,6 @@ async function main() {
105114
}
106115
}
107116

108-
// get command, default is 'dev'
109-
const command = hasCommand ? String(args.shift()) : 'dev'
110-
111117
// proxy https://deno.land/x/aleph
112118
if (['dev', 'start', 'build'].includes(command) && existsFileSync('./import_map.json')) {
113119
const { imports } = JSON.parse(Deno.readTextFileSync('./import_map.json'))

cli/build.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import Project from '../project.ts'
22

3-
export const helpMessage = `Builds the aleph app in production mode.
4-
3+
export const helpMessage = `
54
Usage:
65
aleph build <dir> [...options]
76

cli/dev.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { start } from '../server.ts'
22

3-
export const helpMessage = `Starts the aleph app in development mode.
4-
3+
export const helpMessage = `
54
Usage:
65
aleph dev <dir> [...options]
76

cli/init.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ import log from '../log.ts'
33
import { colors, ensureDir, ensureFile, fromStreamReader, path, Untar } from '../std.ts'
44
import util from '../util.ts'
55

6-
export const helpMessage = `Initiate a new aleph app.
7-
6+
export const helpMessage = `
87
Usage:
98
aleph init <dir> [...options]
109

cli/start.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { start } from '../server.ts'
22

3-
export const helpMessage = `Starts the aleph app in production mode.
4-
3+
export const helpMessage = `
54
Usage:
65
aleph start <dir> [...options]
76

cli/upgrade.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
export const helpMessage = `Upgrade the aleph command.
2-
1+
export const helpMessage = `
32
Usage:
43
aleph upgrade
54

0 commit comments

Comments
 (0)