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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user