Skip to content

Commit 113e752

Browse files
committed
feat: Updated help for all commands
1 parent 2f0f9be commit 113e752

File tree

6 files changed

+86
-34
lines changed

6 files changed

+86
-34
lines changed

src/commands/apply.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,37 @@
11
import { Flags } from '@oclif/core'
2+
import chalk from 'chalk';
23

34
import { BaseCommand } from '../common/base-command.js';
45
import { ApplyOrchestrator } from '../orchestrators/apply.js';
56

67
export default class Apply extends BaseCommand {
7-
static description = 'Apply a codify file onto the system. A plan of the changes is first generated and a list of changes will be shown before proceeding'
8+
static description =
9+
`Install or update resources on the system based on a codify.json file.
10+
11+
Codify first generates a plan to determine the necessary execution steps. See
12+
${chalk.bold.bgMagenta(' codify plan --help ')} for more details.
13+
The execution plan will be presented and approval will be asked before Codify applies
14+
any changes.
15+
16+
For scripts: use ${chalk.bold.bgMagenta(' --output json ')} which will skip approval and
17+
apply changes directly.
18+
19+
For more information, visit: https://docs.codifycli.com/commands/apply
20+
`
821

922
static flags = {
1023
'sudoPassword': Flags.string({
1124
optional: true,
12-
description: 'Pre-fill the sudo password to automatically use for any commands that require elevated permissions.',
25+
description: 'Automatically use this password for any commands that require elevated permissions.',
1326
char: 'S'
1427
}),
1528
}
1629

1730
static examples = [
1831
'<%= config.bin %> <%= command.id %>',
1932
'<%= config.bin %> <%= command.id %> --path ~',
33+
'<%= config.bin %> <%= command.id %> -o json',
34+
'<%= config.bin %> <%= command.id %> -S <sudo password>',
2035
]
2136

2237
async init(): Promise<void> {

src/commands/destroy.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,35 @@
11
import { Flags } from '@oclif/core';
2+
import chalk from 'chalk';
23

34
import { BaseCommand } from '../common/base-command.js';
45
import { DestroyOrchestrator } from '../orchestrators/destroy.js';
56

67
export default class Destroy extends BaseCommand {
78
static strict = false;
8-
static description = 'Destroy or uninstall a resource (or many resources).'
9+
static description =
10+
`Use Codify to uninstall a supported package or setting on the system.
11+
12+
This command will only work for resources with Codify support. This command
13+
can work with or without a codify.json file.
14+
15+
${chalk.bold('Modes:')}
16+
• If a codify.json file exists, destroy the resource specified in the Codify.json file
17+
with a matching type.
18+
• If a codify.json file doesn't exist, additional information may be asked to identify
19+
the specific resource to destroy.
20+
21+
For more information, visit: https://docs.codifycli.com/commands/destory`
22+
923
static examples = [
1024
'<%= config.bin %> <%= command.id %> homebrew nvm',
25+
'<%= config.bin %> <%= command.id %> homebrew nvm --path=~',
26+
'<%= config.bin %> <%= command.id %>',
1127
]
1228

1329
static flags = {
1430
'sudoPassword': Flags.string({
1531
optional: true,
16-
description: 'Pre-fill the sudo password to automatically use for any commands that require elevated permissions.',
32+
description: 'Automatically use this password for any commands that require elevated permissions.',
1733
char: 'S',
1834
helpValue: '<password>'
1935
}),

src/commands/import.ts

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import chalk from 'chalk';
12
import fs from 'node:fs/promises';
23
import path from 'node:path';
34

@@ -8,24 +9,34 @@ import { ShellUtils } from '../utils/shell.js';
89
export default class Import extends BaseCommand {
910
static strict = false;
1011
static override description =
11-
`Generate codify configs from already installed packages. Use a list of space separated arguments to specify the resource types to import. Leave blank to import all resource in an existing *.codify.json file.
12+
`Generate Codify configurations from already installed packages. Use a space-separated list of
13+
arguments to specify the resource types to import. If a codify.json file already
14+
exists, omit arguments to update the file to match the system.
1215
13-
Modes:
14-
1. No args: if no args are specified and an *.codify.json already exists. Then codify will update the existing file with any new changes to the resources specified in the file/files.
16+
${chalk.bold('Modes:')}
17+
1. ${chalk.bold('No args:')} If no args are specified and an *.codify.json already exists, Codify
18+
will update the existing file with new changes on the system.
1519
16-
Command: codify import
20+
${chalk.underline('Command:')}
21+
codify import
1722
18-
2. With args: specify specific resources to import using arguments. Wild card matching is supported using '*' and ? (Note: in zsh * expands to the current dir and needs to be escaped using \\* or '*'). A prompt will be shown if more information is required to complete the import.
23+
2. ${chalk.bold('With args:')} Specify specific resources to import using arguments. Wild card matching is supported
24+
using '*' and '?' (${chalk.italic('Note: in zsh * expands to the current dir and needs to be escaped using \\* or \'*\'')}).
25+
A prompt will be shown if more information is required to complete the import.
1926
20-
Example: codify import nvm asdf\\*, codify import \\* (for importing all supported resources)
27+
${chalk.underline('Examples:')}
28+
codify import nvm asdf
29+
codify import \\*,
30+
codify import \\* (for importing all supported resources)
2131
22-
The results can then be saved:
32+
The results can be saved in one of three ways:
2333
a. To an existing *.codify.json file
2434
b. To a new file
25-
c. Or only printed to console
35+
c. Printed to the console only
2636
27-
Codify will try to smartly insert new configs by following existing spacing and formatting.
28-
`
37+
Codify will attempt to smartly insert new configurations while preserving existing spacing and formatting.
38+
39+
For more information, visit: https://docs.codifycli.com/commands/import`
2940

3041
static override examples = [
3142
'<%= config.bin %> <%= command.id %> homebrew nvm asdf\\*',

src/commands/init.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,27 @@
1-
import fs from 'node:fs/promises';
1+
import chalk from 'chalk';
22

33
import { BaseCommand } from '../common/base-command.js';
44
import { InitializeOrchestrator } from '../orchestrators/init.js';
5-
import { ShellUtils } from '../utils/shell.js';
65

76
export default class Init extends BaseCommand {
87
static strict = false;
8+
99
static override description =
10-
`Initialize codify.`
10+
`A helper to quickly get started with Codify.
11+
12+
Use this command to automatically generate Codify configs based on
13+
the currently installed system resources. By default, the new file
14+
will be written to ${chalk.bold.bgMagenta(' ~/codify.json ')}.
15+
16+
For more information, visit: https://docs.codifycli.com/commands/init`
1117

1218
static baseFlags= {
1319
...BaseCommand.baseFlags,
1420
path: { hidden: true },
1521
}
1622

1723
static override examples = [
18-
'<%= config.bin %> <%= command.id %> homebrew nvm asdf\\*',
1924
'<%= config.bin %> <%= command.id %>',
20-
'<%= config.bin %> <%= command.id %> git-clone --path ../my/other/folder',
21-
'<%= config.bin %> <%= command.id %> \\*'
2225
]
2326

2427
public async run(): Promise<void> {

src/commands/plan.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,25 @@
1+
import chalk from 'chalk';
12
import { BaseCommand } from '../common/base-command.js';
23
import { PlanOrchestrator } from '../orchestrators/plan.js';
34

45
export default class Plan extends BaseCommand {
5-
static description = 'Generate a plan based on a codify.json file. This plan will list ' +
6-
'out the changes Codify will need to make in order to meet the desired config.'
6+
static description =
7+
`Generate an execution plan to apply changes from a codify.json file.
8+
9+
This plan lists all the changes Codify needs to make to apply the codify.json file.
10+
The plan will not be executed. Behind the scenes, Codify performs a refresh scan to
11+
determine the current configuration and installed resources, then compares them with
12+
the desired configuration to compute the execution plan.
13+
14+
For scripts: use ${chalk.bold.bgMagenta(' --output json ')} which will skip all prompts and print
15+
only the final result as a json.
16+
17+
For more information, visit: https://docs.codifycli.com/commands/plan`
718

819
static examples = [
920
'<%= config.bin %> <%= command.id %>',
21+
'<%= config.bin %> <%= command.id %> -o json',
22+
'<%= config.bin %> <%= command.id %> -p ../',
1023
]
1124

1225
async init(): Promise<void> {

src/common/base-command.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export abstract class BaseCommand extends Command {
1818
char: 'o',
1919
default: 'default',
2020
options: ['plain', 'default', 'json'],
21-
description: 'Control the output format of Codify.',
21+
description: 'Control the output format.',
2222
})(),
2323
path: Flags.string({ char: 'p', description: 'Path to run Codify from.' }),
2424
}
@@ -34,6 +34,11 @@ export abstract class BaseCommand extends Command {
3434
strict: false,
3535
});
3636

37+
const debug = createDebug('codify');
38+
if (debug.enabled || flags.debug) {
39+
createDebug.enable('*');
40+
}
41+
3742
const reporterType = this.getReporterType(flags);
3843
this.reporter = ReporterFactory.create(reporterType)
3944

@@ -61,17 +66,6 @@ export abstract class BaseCommand extends Command {
6166
}
6267

6368
private getReporterType(flags: OutputFlags<any>): ReporterType {
64-
const debug = createDebug('codify');
65-
66-
if (debug.enabled || flags.debug) {
67-
createDebug.enable('*');
68-
return ReporterType.DEBUG;
69-
}
70-
71-
if (this.jsonEnabled()) {
72-
return ReporterType.JSON;
73-
}
74-
7569
if (flags.output) {
7670
switch (flags.output) {
7771
case 'debug': {

0 commit comments

Comments
 (0)