Skip to content

Commit a4e39db

Browse files
feat: add examples to --help output for complex commands (#154)
* feat: add examples to --help output for complex commands Adds EXAMPLES sections to field add rich-text, field add content-relationship, field add select, type create, and slice connect. Resolves #148 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: improve examples based on review feedback - Use "Allow any document" instead of "Relate to any document" - Simplify rich-text --allow list - Use marketing-site examples for select field Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * feat: add examples to link, webhook create, token create, and field edit Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: remove trivial token create examples Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 84390d1 commit a4e39db

8 files changed

Lines changed: 77 additions & 0 deletions

src/commands/field-add-content-relationship.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,16 @@ const config = {
3333
supported for fields inside groups (e.g. --field
3434
authors.name).
3535
`,
36+
EXAMPLES: `
37+
Allow any document:
38+
prismic field add content-relationship author --to-type blog_post
39+
40+
Restrict to a specific type:
41+
prismic field add content-relationship category --to-type blog_post --custom-type blog_category
42+
43+
Fetch fields from the related document:
44+
prismic field add content-relationship author --to-type blog_post --custom-type author --field name --field bio
45+
`,
3646
},
3747
positionals: {
3848
id: { description: "Field ID", required: true },

src/commands/field-add-link.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,18 @@ const config = {
1111
name: "prismic field add link",
1212
description:
1313
"Add a link field to a slice or custom type. Use for navigational links to URLs, documents, or media. For data-level relations between documents, use content-relationship instead.",
14+
sections: {
15+
EXAMPLES: `
16+
Add a link that opens in a new tab:
17+
prismic field add link cta --to-type landing_page --allow-target-blank
18+
19+
Restrict to media links only:
20+
prismic field add link download --to-type blog_post --allow media
21+
22+
Add a repeatable link with custom text:
23+
prismic field add link nav_item --to-type navigation --repeatable --allow-text
24+
`,
25+
},
1426
positionals: {
1527
id: { description: "Field ID", required: true },
1628
},

src/commands/field-add-rich-text.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ const config = {
1919
paragraph, strong, em, preformatted, hyperlink, image, embed,
2020
list-item, o-list-item, rtl
2121
`,
22+
EXAMPLES: `
23+
Add a title field (single heading):
24+
prismic field add rich-text title --to-type blog_post --allow heading1 --single
25+
26+
Add a body field with only headings and paragraphs:
27+
prismic field add rich-text body --to-type blog_post --allow heading1,heading2,paragraph,strong,em,hyperlink
28+
`,
2229
},
2330
positionals: {
2431
id: { description: "Field ID", required: true },

src/commands/field-add-select.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@ import { getRepositoryName } from "../project";
1010
const config = {
1111
name: "prismic field add select",
1212
description: "Add a select field to a slice or custom type.",
13+
sections: {
14+
EXAMPLES: `
15+
Add a select with options:
16+
prismic field add select theme --to-type landing_page --option light --option dark --option brand
17+
18+
With a default value:
19+
prismic field add select layout --to-type landing_page --option full --option centered --option sidebar --default-value full
20+
`,
21+
},
1322
positionals: {
1423
id: { description: "Field ID", required: true },
1524
},

src/commands/field-edit.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@ const config = {
1818
type will be applied. See \`prismic field add <type> --help\`
1919
for type-specific option details.
2020
`,
21+
EXAMPLES: `
22+
Rename a field's label:
23+
prismic field edit title --from-type blog_post --label "Page Title"
24+
25+
Change a select field's options:
26+
prismic field edit theme --from-type landing_page --option light --option dark
27+
28+
Restrict a rich text field to a single block:
29+
prismic field edit subtitle --from-type blog_post --single
30+
`,
2131
},
2232
positionals: {
2333
id: { description: "Field ID", required: true },

src/commands/slice-connect.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@ import { getRepositoryName } from "../project";
1010
const config = {
1111
name: "prismic slice connect",
1212
description: "Connect a slice to a type's slice zone.",
13+
sections: {
14+
EXAMPLES: `
15+
Connect a slice to a type's default slice zone:
16+
prismic slice connect hero --to blog_post
17+
18+
Connect to a named slice zone:
19+
prismic slice connect hero --to blog_post --slice-zone page_slices
20+
`,
21+
},
1322
positionals: {
1423
id: { description: "ID of the slice", required: true },
1524
},

src/commands/type-create.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,16 @@ const config = {
3333
page). Includes a slice zone and SEO & Metadata tab by
3434
default, and configures a route in prismic.config.json.
3535
`,
36+
EXAMPLES: `
37+
Create a page type:
38+
prismic type create "Blog Post" --format page
39+
40+
Create a singleton custom type:
41+
prismic type create Settings --single
42+
43+
Create with a custom ID:
44+
prismic type create "Landing Page" --format page --id landing
45+
`,
3646
},
3747
} satisfies CommandConfig;
3848

src/commands/webhook-create.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,16 @@ const config = {
3737
3838
If no triggers specified, all are enabled.
3939
`,
40+
EXAMPLES: `
41+
Create a webhook for all events:
42+
prismic webhook create https://example.com/webhook
43+
44+
Create a webhook for specific events:
45+
prismic webhook create https://example.com/webhook -t documentsPublished -t documentsUnpublished
46+
47+
Create a named webhook with a secret:
48+
prismic webhook create https://example.com/webhook --name "Deploy" --secret my-secret
49+
`,
4050
},
4151
} satisfies CommandConfig;
4252

0 commit comments

Comments
 (0)