51 lines
1.2 KiB
Go
51 lines
1.2 KiB
Go
package cli
|
|
|
|
import (
|
|
"context"
|
|
"flag"
|
|
"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
|
|
}
|
|
if rejectPositionalArgs(stderr, "run", flags.Args()) {
|
|
return exitUsage
|
|
}
|
|
|
|
if err := app.Run(ctx, app.RunOptions{
|
|
ConfigPath: *configPath,
|
|
DryRun: *dryRun,
|
|
Stdout: stdout,
|
|
}); err != nil {
|
|
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
|
|
|
|
Run discovers local source bundles, plans each configured destination, publishes
|
|
selected outputs unless --dry-run is set, and prints a final status summary.
|
|
`)
|
|
}
|