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.

A failed settings import is reported once (bonfire.Reported).
This commit is contained in:
Jakub Zych
2026-10-21 17:55:58 +02:00
parent e06b14007c
commit ce4b43e121
9 changed files with 224 additions and 11 deletions

View File

@@ -42,12 +42,26 @@ func IsNothingToImport(err error) bool {
func ImportSettings(app *backpack.App) bonfire.Command {
return bonfire.Command{
Name: "feedback:import-settings",
Description: "Import the WinterCMS golem15_feedback_settings row into golem15_feedback_settings, once.",
Description: "Import the WinterCMS feedback widget settings row, once",
Long: `Copies the WinterCMS feedback widget settings (the system_settings row
golem15_feedback_settings of this database) into the plugin's settings,
including the widget key, so the embed snippets on existing sites keep
working.
Run it once after copying a WinterCMS database. It writes only while the
settings still hold what they were created with (or do not exist yet), so a
second run changes nothing; --force overwrites settings that were already
changed here. A missing system_settings table or row is reported without
failing. It ends with "Imported the feedback widget settings."`,
Flags: []bonfire.Flag{{
Name: "force",
Description: "Overwrite settings that were already changed",
Bare: true,
}},
Examples: []bonfire.Example{
{Command: "feedback:import-settings", Description: "Copy the widget settings from the WinterCMS row"},
{Command: "feedback:import-settings --force", Description: "Copy them over settings that were already changed"},
},
Run: func(ctx context.Context, in bonfire.Input, out bonfire.Output) error {
if app == nil {
return errors.New("feedback:import-settings: app is nil")
@@ -65,7 +79,7 @@ func ImportSettings(app *backpack.App) bonfire.Command {
return nil
case err != nil:
out.Error(err.Error())
return err
return bonfire.Reported(err)
}
out.Success("Imported the feedback widget settings.")
return nil