feat: console help, examples and named loggers (SummerCMS v0.4.0)
Every command gets long help and examples, descriptions in imperative sentence case, and a warn-only TestCommandsDocumented over bonfire.CheckDocs. The plugin logs through a diary component logger instead of the process default logger. Requires SummerCMS v0.4.0; command names and flags unchanged.
This commit is contained in:
@@ -47,11 +47,26 @@ func ImportWinter(app *backpack.App) bonfire.Command {
|
||||
return bonfire.Command{
|
||||
Name: "faq:import-winter",
|
||||
Description: "Copy a WinterCMS FAQ export into this application",
|
||||
Long: `Copies the FAQs of a WinterCMS site (the JSON lines that
|
||||
scripts/winter-export.sql prints) into this application's FAQ table, keeping
|
||||
their ids, content and timestamps, and moves the id sequence past the copied
|
||||
ids. Each FAQ's locale is looked up by its code among the translate locales;
|
||||
an unknown code stops the import before anything is written.
|
||||
|
||||
Run it once when an application moves from WinterCMS, --dry-run first:
|
||||
--dry-run counts the FAQs and writes nothing. A table that already holds
|
||||
FAQs is refused unless --force is given, which replaces them in the same
|
||||
transaction. It ends with "Copied N FAQs."`,
|
||||
Flags: []bonfire.Flag{
|
||||
{Name: "file", Description: "FAQ export (JSON lines from scripts/winter-export.sql)"},
|
||||
{Name: "force", Description: "Replace the FAQs the table already holds", Bare: true},
|
||||
{Name: "dry-run", Description: "Report what would be copied without writing", Bare: true},
|
||||
},
|
||||
Examples: []bonfire.Example{
|
||||
{Command: "faq:import-winter --file faqs.jsonl --dry-run", Description: "Count the FAQs the export would copy, without writing"},
|
||||
{Command: "faq:import-winter --file faqs.jsonl", Description: "Copy the FAQs onto a fresh application"},
|
||||
{Command: "faq:import-winter --file faqs.jsonl --force", Description: "Replace the FAQs the table already holds"},
|
||||
},
|
||||
Run: func(ctx context.Context, in bonfire.Input, out bonfire.Output) error {
|
||||
opts := WinterOptions{
|
||||
File: flagValue(in, "file"),
|
||||
|
||||
Reference in New Issue
Block a user