Documentation
¶
Overview ¶
Package servicecontract defines the human and machine readable description of an application service exposed through product surfaces.
Index ¶
Constants ¶
const ( FlagScopeCommand = "command" FlagScopePersistent = "persistent" )
Flag scope values. A command flag belongs to one operation; a persistent flag is registered once on the root command and read by every operation below it.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Contract ¶
type Contract struct {
ID string `json:"id"`
Summary string `json:"summary"`
Description string `json:"description"`
Operations []Operation `json:"operations"`
}
Contract describes one service and the operations a surface may expose.
type Example ¶
type Example struct {
Command string `json:"command"`
Explanation string `json:"explanation,omitempty"`
}
Example is one worked invocation of an operation.
type FlagSpec ¶
type FlagSpec struct {
Name string `json:"name"`
Shorthand string `json:"shorthand,omitempty"`
Scope string `json:"scope,omitempty"`
Hidden bool `json:"hidden,omitempty"`
}
FlagSpec is the command-line flag an input is reached through.
type Input ¶
type Input struct {
ID string `json:"id"`
Summary string `json:"summary"`
Type string `json:"type"`
Required bool `json:"required,omitempty"`
// Values enumerates the accepted values of a closed input, so a surface can
// offer the choice instead of restating it.
Values []string `json:"values,omitempty"`
// Flag is the command-line spelling of this input. An empty Name means the
// input is reached positionally or not at all.
Flag FlagSpec `json:"flag,omitempty"`
// Positional is the 1-based ordinal this input occupies, or zero when it has
// no positional form.
Positional int `json:"positional,omitempty"`
// Variadic marks an input that consumes the remaining positionals and is
// therefore always the last one.
Variadic bool `json:"variadic,omitempty"`
// Default is what the surface applies when the operator states nothing. An
// empty Default means the input has no default.
Default string `json:"default,omitempty"`
// Placeholder is the metavar the synopsis renders for this input.
Placeholder string `json:"placeholder,omitempty"`
// Repeatable marks a flag or positional that may be given more than once.
Repeatable bool `json:"repeatable,omitempty"`
// Presentation marks an input the surface renders and that changes no
// engine input, so a coverage check does not demand a request field for it.
Presentation bool `json:"presentation,omitempty"`
// Deprecated names the replacement or the reason a spelling is kept, so a
// surface can warn instead of silently dropping it.
Deprecated string `json:"deprecated,omitempty"`
}
Input describes one named operation input.
type Operation ¶
type Operation struct {
ID string `json:"id"`
Summary string `json:"summary"`
Description string `json:"description,omitempty"`
Inputs []Input `json:"inputs,omitempty"`
// Spec is the operator-facing body of the operation: what the capability
// is, what it refuses and what it costs. It is the whole of what a surface
// renders as long help.
Spec string `json:"spec,omitempty"`
// Usage is the synopsis a command surface renders after the command path,
// carrying the positional placeholders the operation accepts.
Usage string `json:"usage,omitempty"`
Examples []Example `json:"examples,omitempty"`
Output Output `json:"output,omitempty"`
Outcomes []Outcome `json:"outcomes,omitempty"`
// Gate names the visibility gate the operation sits behind, so a surface
// hides it rather than offering a command that cannot run.
Gate string `json:"gate,omitempty"`
Refusals []Refusal `json:"refusals,omitempty"`
}
Operation describes one callable operation.
type Outcome ¶
type Outcome struct {
Code int `json:"code"`
When string `json:"when"`
Meaning string `json:"meaning,omitempty"`
}
Outcome is one terminal status an operation reports.