fix: journal:fix-headings runs from the application CLI
The command opens the database with lookupDB, as journal:image-variants does: without a published database it opens database.dsn, and without a DSN it names SUMMER_DATABASE__DSN.
This commit is contained in:
@@ -2,7 +2,6 @@ package console
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"git.golem15.com/golem15/sm-journal-plugin/classes"
|
||||
@@ -13,8 +12,10 @@ import (
|
||||
// FixHeadings is journal:fix-headings: it converts H1 to H2 in stored
|
||||
// Journal rich text (post content in every locale and category pillar text)
|
||||
// while the Journal H1 setting is on. It is a dry run unless --apply is
|
||||
// given; with the setting off it refuses with exit code 1. Its output (UI-SPEC
|
||||
// C27 with the P33-54 wording, English only):
|
||||
// given; with the setting off it refuses with exit code 1. It runs from the
|
||||
// generated application CLI: without a published database it opens
|
||||
// database.dsn (lookupDB) and, without one, names SUMMER_DATABASE__DSN. Its
|
||||
// output (UI-SPEC C27 with the P33-54 wording, English only):
|
||||
//
|
||||
// - dry run: "Would convert :count H1 headings in :posts posts and :categories categories. Run with --apply to save."
|
||||
// - applied: "Converted :count H1 headings in :posts posts and :categories categories."
|
||||
@@ -47,10 +48,11 @@ journal_fix_headings runs the same conversion.`,
|
||||
{Command: "journal:fix-headings --apply", Description: "Convert them and save"},
|
||||
},
|
||||
Run: func(ctx context.Context, in bonfire.Input, out bonfire.Output) error {
|
||||
db := mustDB(app)
|
||||
if db == nil {
|
||||
return errors.New("journal: database is not configured")
|
||||
db, done, err := lookupDB(ctx, app)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer done()
|
||||
if !classes.EffectiveH1ToH2(ctx, db, appConfig(app)) {
|
||||
out.Error(classes.H1ConversionOffText)
|
||||
return bonfire.Reported(classes.ErrH1ConversionOff)
|
||||
|
||||
Reference in New Issue
Block a user