Route executions through neutral snapshots
This commit is contained in:
66
internal/commandmeta/metadata.go
Normal file
66
internal/commandmeta/metadata.go
Normal file
@@ -0,0 +1,66 @@
|
||||
// Package commandmeta owns the neutral metadata exchanged by CommandKit and
|
||||
// its command-line backend.
|
||||
package commandmeta
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
)
|
||||
|
||||
// Key identifies one command inside one routing snapshot.
|
||||
type Key uint64
|
||||
|
||||
// Command describes one node in a neutral command tree.
|
||||
type Command struct {
|
||||
Key Key
|
||||
Name string
|
||||
Summary string
|
||||
Description string
|
||||
Runnable bool
|
||||
Flags []Flag
|
||||
Arguments []Argument
|
||||
Children []*Command
|
||||
}
|
||||
|
||||
// Argument describes one positional input for usage rendering.
|
||||
type Argument struct {
|
||||
Name string
|
||||
Usage string
|
||||
Min int
|
||||
Max int
|
||||
}
|
||||
|
||||
// Flag describes one local option without exposing a backend value.
|
||||
type Flag struct {
|
||||
Name string
|
||||
Short string
|
||||
Usage string
|
||||
Default string
|
||||
Boolean bool
|
||||
Repeated bool
|
||||
Required bool
|
||||
}
|
||||
|
||||
// Failure is a neutral parsing or presentation failure.
|
||||
type Failure struct {
|
||||
Message string
|
||||
Usage bool
|
||||
}
|
||||
|
||||
// Result contains the selected command and raw input collected by the adapter.
|
||||
type Result struct {
|
||||
Key Key
|
||||
Path []string
|
||||
HelpRequested bool
|
||||
FlagValues [][]string
|
||||
Operands []string
|
||||
Failure *Failure
|
||||
}
|
||||
|
||||
// ParseOptions makes parser context and streams explicit.
|
||||
type ParseOptions struct {
|
||||
Context context.Context
|
||||
In io.Reader
|
||||
Out io.Writer
|
||||
Err io.Writer
|
||||
}
|
||||
Reference in New Issue
Block a user