feat(11.1-03): add the Setup and Console docs sections
- setup: introduction, installation rewritten from install to serve, configuration with the keys an application sets - console: introduction, setup and maintenance, scaffolding, writing commands, utilities; every command name is checker-verified - bonfire ExampleCatalog shows arguments, bare and repeatable flags - index links the section introductions; TestDocsRequiredPages lists the seven new pages
This commit is contained in:
@@ -25,3 +25,29 @@ func ExampleCall() {
|
||||
}
|
||||
// Output: Hello, blog
|
||||
}
|
||||
|
||||
func ExampleCatalog() {
|
||||
publish := bonfire.Command{
|
||||
Name: "blog:publish",
|
||||
Description: "Publish a post",
|
||||
Args: []bonfire.Arg{{Name: "slug", Description: "Post slug", Required: true}},
|
||||
Flags: []bonfire.Flag{
|
||||
{Name: "dry-run", Description: "Report without writing", Bare: true},
|
||||
{Name: "tag", Description: "Tag to add (repeatable)", Repeatable: true},
|
||||
},
|
||||
Run: func(ctx context.Context, in bonfire.Input, out bonfire.Output) error {
|
||||
slug, _ := in.Argument("slug")
|
||||
dryRun, _ := in.Flag("dry-run")
|
||||
out.Printf("publish %s, tags %v, dry run %s\n", slug, in.Flags("tag"), dryRun)
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
// The generated main publishes a catalog of every command on the app.
|
||||
catalog := bonfire.NewCatalog([]bonfire.Command{publish})
|
||||
args := []string{"hello-world", "--tag", "news", "--tag", "go", "--dry-run"}
|
||||
if err := catalog.Call(context.Background(), "blog:publish", args, os.Stdout); err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
// Output: publish hello-world, tags [news go], dry run true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user