diff --git a/src/cli/setup.ts b/src/cli/setup.ts index a42eadc..a10a659 100644 --- a/src/cli/setup.ts +++ b/src/cli/setup.ts @@ -1,6 +1,7 @@ import { program } from 'commander' import color from 'kleur' + import pkg from '../../package.json' import { cleanApp, @@ -41,13 +42,11 @@ program } return '' }) + .addHelpCommand(false) .configureOutput({ writeOut: (str) => { const colored = str - .replace(/^(Usage:)/gm, color.yellow('$1')) - .replace(/^(Commands:)/gm, color.yellow('$1')) - .replace(/^(Options:)/gm, color.yellow('$1')) - .replace(/^(Arguments:)/gm, color.yellow('$1')) + .replace(/^([A-Z][\w ]*:)/gm, color.yellow('$1')) process.stdout.write(colored) }, }) @@ -56,44 +55,88 @@ program .command('version', { hidden: true }) .action(() => console.log(program.version())) -program - .command('config') - .description('Show current host configuration') - .action(configShow) - -program - .command('info') - .description('Show info for an app') - .argument('[name]', 'app name (uses current directory if omitted)') - .action(infoApp) +// Apps program .command('list') + .helpGroup('Apps:') .description('List all apps') .option('-t, --tools', 'show only tools') .option('-a, --apps', 'show only apps (exclude tools)') .action(listApps) +program + .command('info') + .helpGroup('Apps:') + .description('Show info for an app') + .argument('[name]', 'app name (uses current directory if omitted)') + .action(infoApp) + +program + .command('new') + .helpGroup('Apps:') + .description('Create a new toes app') + .argument('[name]', 'app name (uses current directory if omitted)') + .option('--ssr', 'SSR template with pages directory (default)') + .option('--bare', 'minimal template with no pages') + .option('--spa', 'single-page app with client-side rendering') + .action(newApp) + +program + .command('get') + .helpGroup('Apps:') + .description('Download an app from server') + .argument('', 'app name') + .action(getApp) + +program + .command('open') + .helpGroup('Apps:') + .description('Open an app in browser') + .argument('[name]', 'app name (uses current directory if omitted)') + .action(openApp) + +program + .command('rename') + .helpGroup('Apps:') + .description('Rename an app') + .argument('[name]', 'app name (uses current directory if omitted)') + .argument('', 'new app name') + .action(renameApp) + +program + .command('rm') + .helpGroup('Apps:') + .description('Remove an app from the server') + .argument('[name]', 'app name (uses current directory if omitted)') + .action(rmApp) + +// Lifecycle + program .command('start') + .helpGroup('Lifecycle:') .description('Start an app') .argument('[name]', 'app name (uses current directory if omitted)') .action(startApp) program .command('stop') + .helpGroup('Lifecycle:') .description('Stop an app') .argument('[name]', 'app name (uses current directory if omitted)') .action(stopApp) program .command('restart') + .helpGroup('Lifecycle:') .description('Restart an app') .argument('[name]', 'app name (uses current directory if omitted)') .action(restartApp) program .command('logs') + .helpGroup('Lifecycle:') .description('Show logs for an app') .argument('[name]', 'app name (uses current directory if omitted)') .option('-f, --follow', 'follow log output') @@ -113,59 +156,47 @@ program program .command('stats') + .helpGroup('Lifecycle:') .description('Show CPU and memory stats for apps') .argument('[name]', 'app name (uses current directory if omitted)') .action(statsApp) -program - .command('open') - .description('Open an app in browser') - .argument('[name]', 'app name (uses current directory if omitted)') - .action(openApp) - -program - .command('get') - .description('Download an app from server') - .argument('', 'app name') - .action(getApp) - -program - .command('new') - .description('Create a new toes app') - .argument('[name]', 'app name (uses current directory if omitted)') - .option('--ssr', 'SSR template with pages directory (default)') - .option('--bare', 'minimal template with no pages') - .option('--spa', 'single-page app with client-side rendering') - .action(newApp) +// Sync program .command('push') + .helpGroup('Sync:') .description('Push local changes to server') .action(pushApp) program .command('pull') + .helpGroup('Sync:') .description('Pull changes from server') .option('-f, --force', 'overwrite local changes') .action(pullApp) program .command('status') + .helpGroup('Sync:') .description('Show what would be pushed/pulled') .action(statusApp) program .command('diff') + .helpGroup('Sync:') .description('Show diff of changed files') .action(diffApp) program .command('sync') + .helpGroup('Sync:') .description('Watch and sync changes bidirectionally') .action(syncApp) program .command('clean') + .helpGroup('Sync:') .description('Remove local files not on server') .option('-f, --force', 'skip confirmation') .option('-n, --dry-run', 'show what would be removed') @@ -173,6 +204,7 @@ program const stash = program .command('stash') + .helpGroup('Sync:') .description('Stash local changes') .action(stashApp) @@ -186,8 +218,17 @@ stash .description('List all stashes') .action(stashListApp) +// Config + +program + .command('config') + .helpGroup('Config:') + .description('Show current host configuration') + .action(configShow) + const env = program .command('env') + .helpGroup('Config:') .description('Manage environment variables') .argument('[name]', 'app name (uses current directory if omitted)') .action(envList) @@ -209,28 +250,17 @@ env program .command('versions') + .helpGroup('Config:') .description('List deployed versions') .argument('[name]', 'app name (uses current directory if omitted)') .action(versionsApp) program .command('rollback') + .helpGroup('Config:') .description('Rollback to a previous version') .argument('[name]', 'app name (uses current directory if omitted)') .option('-v, --version ', 'version to rollback to (prompts if omitted)') .action((name, options) => rollbackApp(name, options.version)) -program - .command('rm') - .description('Remove an app from the server') - .argument('[name]', 'app name (uses current directory if omitted)') - .action(rmApp) - -program - .command('rename') - .description('Rename an app') - .argument('[name]', 'app name (uses current directory if omitted)') - .argument('', 'new app name') - .action(renameApp) - export { program }