Files
distributor/internal/cli/run.go

51 lines
1.2 KiB
Go
Raw Normal View History

2026-05-31 01:47:39 +00:00
package cli
import (
"context"
"flag"
2026-05-31 01:47:39 +00:00
"fmt"
"io"
"gitea.maximumdirect.net/eric/distributor/internal/app"
)
func runCommand(ctx context.Context, args []string, stdout, stderr io.Writer) int {
if hasHelp(args) {
printRunHelp(stdout)
return exitOK
}
flags := flag.NewFlagSet("run", flag.ContinueOnError)
flags.SetOutput(stderr)
configPath := flags.String("config", "", "path to config file")
dryRun := flags.Bool("dry-run", false, "load and validate config without publishing")
if err := flags.Parse(args); err != nil {
return exitUsage
}
2026-05-31 03:31:57 +00:00
if rejectPositionalArgs(stderr, "run", flags.Args()) {
2026-05-31 01:47:39 +00:00
return exitUsage
}
if err := app.Run(ctx, app.RunOptions{
ConfigPath: *configPath,
DryRun: *dryRun,
Stdout: stdout,
}); err != nil {
2026-05-31 01:47:39 +00:00
return fail(stderr, err)
}
return exitOK
}
func printRunHelp(w io.Writer) {
fmt.Fprint(w, `Usage:
distributor run --config <path> --dry-run
Options:
--config <path> Path to config file
--dry-run Load and validate config without publishing
2026-05-31 01:47:39 +00:00
2026-05-31 02:33:09 +00:00
Run discovers local source bundles, plans each configured destination, publishes
selected outputs unless --dry-run is set, and prints a final status summary.
2026-05-31 01:47:39 +00:00
`)
}