feat(bonfire): add FlagBool and read every bare switch with it (IN-04, quick-261028-rqd)

This commit is contained in:
Jakub Zych
2026-10-28 20:32:38 +01:00
parent e34d113c80
commit 795c4f6b29
15 changed files with 86 additions and 54 deletions

View File

@@ -8,7 +8,6 @@ import (
"os"
"os/signal"
"slices"
"strconv"
"strings"
"syscall"
"time"
@@ -84,10 +83,8 @@ scheduled queue.`,
Bare: true,
}},
Run: func(ctx context.Context, in bonfire.Input, out bonfire.Output) error {
if v, ok := in.Flag("once"); ok {
if once, _ := strconv.ParseBool(v); once {
return scheduleRunOnce(ctx, app, plugins, scheduleNow(), out)
}
if bonfire.FlagBool(in, "once") {
return scheduleRunOnce(ctx, app, plugins, scheduleNow(), out)
}
return withDB(ctx, app, func() error {
return runScheduler(ctx, app, plugins, out)
@@ -382,12 +379,8 @@ func clearQueue(ctx context.Context, app *backpack.App, queue string, out bonfir
// --force is set (D-28). Off a terminal, under -n or -q and in
// bonfire.Call it never asks. A "no" returns a Reported error (exit 1).
func confirmProduction(app *backpack.App, in bonfire.Input, out bonfire.Output, question string) error {
if in != nil {
if v, ok := in.Flag("force"); ok {
if force, _ := strconv.ParseBool(v); force {
return nil
}
}
if bonfire.FlagBool(in, "force") {
return nil
}
if app == nil || app.Config == nil || app.Config.Environment() != "production" {
return nil