Skip to content

Commit

Permalink
docs: use new customUsage feature in docs
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Molisani <git@molisani.us>
  • Loading branch information
molisani authored and mkubilayk committed Nov 4, 2024
1 parent d78fda3 commit 3cf23f9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
6 changes: 3 additions & 3 deletions docs/docs/features/argument-parsing/examples/boolean-flag.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ export const root = buildCommand({
docs: {
brief: "Example for live playground with boolean flag",
customUsage: [
"--quiet",
"--quiet=yes",
"--noQuiet",
{ input: "--quiet", brief: "Flag with no value" },
{ input: "--quiet=yes", brief: "Flag with explicit value" },
{ input: "--noQuiet", brief: "Negated flag" },
],
},
});
5 changes: 4 additions & 1 deletion docs/docs/features/command-routing/commands.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ The parameters object is a specification of all of the parameters (arguments and

A base level of documentation is required, and more is always appreciated. All commands must specify a value for `brief` that contains a short line of text to be used when referring to this command throughout the help text of the application.

Optionally, you can further customize the help text for this specific command by including `fullDescription` or `customUsage`. The former will override `brief` in the command's help text and can contain multiple lines of text rather than just one. The `customUsage` property will replace the auto-generated usage lines, and is useful when there's some [additional validation of user inputs](../out-of-scope.mdx#cross-argument-validation) that isn't represented natively by Stricli.
Optionally, you can further customize the help text for this specific command by including `fullDescription` or `customUsage`. The former will override `brief` in the command's help text and can contain multiple lines of text rather than just one. The `customUsage` property will replace the auto-generated usage lines, and is useful when there's some [additional validation of user inputs](../out-of-scope.mdx#cross-argument-validation) that isn't represented natively by Stricli. You can also provide an object with `input` and `brief` to print a description after the usage line.

```ts
// output-next-line
Expand All @@ -84,6 +84,7 @@ buildCommand({
customUsage: [
"-a -b",
"-c",
{ input: "-d", brief: "Brief description of this use case" },
],
},
...
Expand All @@ -98,6 +99,8 @@ run --help
USAGE
run -a -b
run -c
run -d
Brief description of this use case
run --help

This is the full description of the command.
Expand Down
6 changes: 5 additions & 1 deletion packages/core/tests/application.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,11 @@ describe("Application", () => {
},
docs: {
brief: "basic command",
customUsage: ["custom usage 1", { input: "custom-two", brief: "enhanced custom usage 2" }, "custom usage 3"],
customUsage: [
"custom usage 1",
{ input: "custom-two", brief: "enhanced custom usage 2" },
"custom usage 3",
],
},
});
const appWithAlternateUsage = buildApplication(commandWithAlternateUsage, {
Expand Down

0 comments on commit 3cf23f9

Please sign in to comment.