feat: console help and examples (SummerCMS v0.4.0)

golem:import-settings gets long help and examples, a description in
sentence case without a trailing period, and a warn-only
TestCommandsDocumented over bonfire.CheckDocs. A failed import is reported
once (bonfire.Reported). Requires SummerCMS v0.4.0; the command name and
its flag are unchanged.
This commit is contained in:
Jakub Zych
2026-10-21 17:54:21 +02:00
parent 544aa287f0
commit 37748aea68
5 changed files with 191 additions and 7 deletions

View File

@@ -34,11 +34,25 @@ const SettingsItem = "golem_settings"
func ImportSettings(app *backpack.App) bonfire.Command {
return bonfire.Command{
Name: "golem:import-settings",
Description: "Import the AI models of a WinterCMS golem_settings row (or a JSON file) into golem15_golem_models, once.",
Description: "Import the AI models of a WinterCMS golem_settings row (or a JSON file), once",
Long: `Copies the AI models of a WinterCMS installation into this application's AI
models table, in the order of the PHP repeater: by default from the models
repeater of the system_settings row golem_settings in this database, or from
the JSON file given with --file (the settings value {"models": [...]} or the
models list itself). Each plaintext API key is encrypted on write.
Run it once after copying a WinterCMS database. It refuses to run when the
table already has rows, so a second run changes nothing; a missing
system_settings table or row is reported without failing. It ends with
"Imported N AI models."`,
Flags: []bonfire.Flag{{
Name: "file",
Description: "A JSON file holding the settings value ({\"models\":[...]}) or the models list, read instead of system_settings",
}},
Examples: []bonfire.Example{
{Command: "golem:import-settings", Description: "Copy the models from the golem_settings row of this database"},
{Command: "golem:import-settings --file golem-settings.json", Description: "Copy the models from an exported settings value"},
},
Run: func(ctx context.Context, in bonfire.Input, out bonfire.Output) error {
if app == nil {
return errors.New("golem:import-settings: app is nil")
@@ -56,7 +70,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(fmt.Sprintf("Imported %d AI models.", n))
return nil