33 lines
670 B
Go
33 lines
670 B
Go
package cli
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"io"
|
|
|
|
"gitea.maximumdirect.net/eric/distributor/internal/app"
|
|
)
|
|
|
|
func validateCommand(ctx context.Context, args []string, stdout, stderr io.Writer) int {
|
|
if hasHelp(args) {
|
|
printValidateHelp(stdout)
|
|
return exitOK
|
|
}
|
|
path, ok := parseOptionalPathArg(stderr, "validate", args)
|
|
if !ok {
|
|
return exitUsage
|
|
}
|
|
if err := app.Validate(ctx, app.ValidateOptions{Path: path, Stdout: stdout}); err != nil {
|
|
return fail(stderr, err)
|
|
}
|
|
return exitOK
|
|
}
|
|
|
|
func printValidateHelp(w io.Writer) {
|
|
fmt.Fprint(w, `Usage:
|
|
distributor validate <path>
|
|
|
|
Validate a local source bundle directory or a tree containing source bundles.
|
|
`)
|
|
}
|