Skip to content

Commit e635828

Browse files
authored
feat: improve CLI help output (#4)
Adds example commands to help output, fixes usage line, corrects subcommand ordering, and makes version dynamic from package.json. Co-authored-by: Ben Sabic <bensabic@users.noreply.github.com>
1 parent 45d52c6 commit e635828

11 files changed

Lines changed: 48 additions & 24 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ memberstack whoami
3131
## Usage
3232

3333
```bash
34-
memberstack <command> <subcommand> [options]
34+
memberstack <command> [subcommand] [params] [options]
3535
```
3636

3737
## Install Agent Skill (Optional)

src/commands/apps.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ const APP_FIELDS = `
3737
allowMemberSelfDelete
3838
`;
3939

40-
export const appsCommand = new Command("apps").description("Manage apps");
40+
export const appsCommand = new Command("apps")
41+
.usage("<command> [options]")
42+
.description("Manage apps");
4143

4244
appsCommand
4345
.command("current")

src/commands/auth.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@ const findAvailablePort = (): Promise<number> =>
110110
server.on("error", reject);
111111
});
112112

113-
export const authCommand = new Command("auth").description(
114-
"Manage OAuth authentication"
115-
);
113+
export const authCommand = new Command("auth")
114+
.usage("<command> [options]")
115+
.description("Manage OAuth authentication");
116116

117117
authCommand
118118
.command("login")

src/commands/custom-fields.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ const CUSTOM_FIELD_FIELDS = `
3232
tableOrder
3333
`;
3434

35-
export const customFieldsCommand = new Command("custom-fields").description(
36-
"Manage custom fields"
37-
);
35+
export const customFieldsCommand = new Command("custom-fields")
36+
.usage("<command> [options]")
37+
.description("Manage custom fields");
3838

3939
customFieldsCommand
4040
.command("list")

src/commands/members.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,9 @@ const collect = (value: string, previous: string[]): string[] => [
194194
value,
195195
];
196196

197-
export const membersCommand = new Command("members").description(
198-
"Manage members"
199-
);
197+
export const membersCommand = new Command("members")
198+
.usage("<command> [options]")
199+
.description("Manage members");
200200

201201
membersCommand
202202
.command("list")

src/commands/plans.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,9 @@ const parseRedirects = (entries: string[]): Record<string, string> => {
140140
return redirects;
141141
};
142142

143-
export const plansCommand = new Command("plans").description("Manage plans");
143+
export const plansCommand = new Command("plans")
144+
.usage("<command> [options]")
145+
.description("Manage plans");
144146

145147
plansCommand
146148
.command("list")

src/commands/records.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ const resolveTableId = async (tableKey: string): Promise<string> => {
7272
return result.dataTable.id;
7373
};
7474

75-
export const recordsCommand = new Command("records").description(
76-
"Manage data table records"
77-
);
75+
export const recordsCommand = new Command("records")
76+
.usage("<command> [options]")
77+
.description("Manage data table records");
7878

7979
recordsCommand
8080
.command("create")

src/commands/skills.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ const runSkillsCommand = async (args: string[]): Promise<void> => {
1212
await execAsync(`npx skills ${args.join(" ")}`);
1313
};
1414

15-
export const skillsCommand = new Command("skills").description(
16-
"Manage Memberstack skills"
17-
);
15+
export const skillsCommand = new Command("skills")
16+
.usage("<command> [options]")
17+
.description("Manage Memberstack skills");
1818

1919
skillsCommand
2020
.command("add")

src/commands/tables.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ const TABLE_FIELDS = `
6161
}
6262
`;
6363

64-
export const tablesCommand = new Command("tables").description(
65-
"Manage data tables"
66-
);
64+
export const tablesCommand = new Command("tables")
65+
.usage("<command> [options]")
66+
.description("Manage data tables");
6767

6868
tablesCommand
6969
.command("list")

src/lib/program.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,24 @@
11
import { Command } from "commander";
22

3+
declare const __VERSION__: string | undefined;
4+
const version = typeof __VERSION__ !== "undefined" ? __VERSION__ : "dev";
5+
36
export const program = new Command();
47

58
program
6-
.name("Memberstack CLI")
9+
.name("memberstack")
10+
.usage("<command> [subcommand] [params] [options]")
711
.description("Manage your Memberstack account from the terminal.")
8-
.version("0.0.0")
12+
.version(version)
913
.option("-j, --json", "Output raw JSON instead of formatted tables")
10-
.option("--live", "Use live environment instead of sandbox");
14+
.option("--live", "Use live environment instead of sandbox")
15+
.addHelpText(
16+
"after",
17+
`
18+
Examples:
19+
$ memberstack auth login
20+
$ memberstack members list --json
21+
$ memberstack plans create --name "Pro Plan"
22+
$ memberstack records find users --where "status equals active"
23+
$ memberstack skills add memberstack-cli`
24+
);

0 commit comments

Comments
 (0)