48 lines
1.2 KiB
Go
48 lines
1.2 KiB
Go
package cli
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"io"
|
|
|
|
"gitea.maximumdirect.net/eric/distributor/internal/app"
|
|
)
|
|
|
|
func inspectCommand(ctx context.Context, args []string, stdout, stderr io.Writer) int {
|
|
if hasHelp(args) {
|
|
printInspectHelp(stdout)
|
|
return exitOK
|
|
}
|
|
parsed, ok := parseSourceDiagnosticArgs(stderr, "inspect", args)
|
|
if !ok {
|
|
return exitUsage
|
|
}
|
|
if err := app.Inspect(ctx, app.InspectOptions{
|
|
Path: parsed.Path,
|
|
ConfigPath: parsed.ConfigPath,
|
|
PipelineID: parsed.PipelineID,
|
|
BundlePath: parsed.BundlePath,
|
|
Stdout: stdout,
|
|
OutputFormat: parsed.OutputFormat,
|
|
}); err != nil {
|
|
return fail(stderr, err)
|
|
}
|
|
return exitOK
|
|
}
|
|
|
|
func printInspectHelp(w io.Writer) {
|
|
fmt.Fprint(w, `Usage:
|
|
distributor inspect [--format text|json] <path>
|
|
distributor inspect --config <path> --pipeline <id> [--bundle <path>] [--format text|json]
|
|
|
|
Options:
|
|
--config <path> Path to config file for configured source inspection
|
|
--pipeline <id> Pipeline id to inspect in config mode
|
|
--bundle <path> Source-root-relative bundle path to inspect
|
|
--format text|json Output format
|
|
|
|
Print a normalized summary of local source bundles or a configured pipeline
|
|
source.
|
|
`)
|
|
}
|