Documentation
¶
Index ¶
- func NewCmdServiceMethod(f *cmdutil.Factory, svc meta.Service, m meta.Method, name, resName string, ...) *cobra.Command
- func NewCmdServiceMethodWithContext(ctx context.Context, f *cmdutil.Factory, svc meta.Service, m meta.Method, ...) *cobra.Command
- func RegisterServiceCommands(parent *cobra.Command, f *cmdutil.Factory)
- func RegisterServiceCommandsForNames(ctx context.Context, parent *cobra.Command, f *cmdutil.Factory, ...)
- func RegisterServiceCommandsFromCatalog(ctx context.Context, parent *cobra.Command, f *cmdutil.Factory, ...)
- func RegisterServiceCommandsWithContext(ctx context.Context, parent *cobra.Command, f *cmdutil.Factory)
- type HelpRenderer
- type ServiceMethodOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewCmdServiceMethod ¶
func NewCmdServiceMethod(f *cmdutil.Factory, svc meta.Service, m meta.Method, name, resName string, runF func(*ServiceMethodOptions) error) *cobra.Command
NewCmdServiceMethod creates a command for a dynamically registered service method.
func NewCmdServiceMethodWithContext ¶ added in v1.0.16
func NewCmdServiceMethodWithContext(ctx context.Context, f *cmdutil.Factory, svc meta.Service, m meta.Method, name, resName string, runF func(*ServiceMethodOptions) error) *cobra.Command
NewCmdServiceMethodWithContext builds the command for one service method from its (service, resource, method) coordinates, deriving the methodCommandSpec via an apicatalog.MethodRef so direct callers and the catalog-driven registration assemble the command identically.
func RegisterServiceCommands ¶
RegisterServiceCommands registers every service of f.APICatalog under parent. A zero (unset) Catalog has no services and registers nothing; the root builder is responsible for wiring the Catalog before calling this.
func RegisterServiceCommandsForNames ¶ added in v1.0.95
func RegisterServiceCommandsForNames(ctx context.Context, parent *cobra.Command, f *cmdutil.Factory, catalog apicatalog.Catalog, names []string)
RegisterServiceCommandsForNames registers only the named services from catalog, parsing exactly those shards. Unknown names are skipped; the root builder preloads its selection first so a corrupt shard fails typed before dispatch instead of vanishing here.
func RegisterServiceCommandsFromCatalog ¶ added in v1.0.56
func RegisterServiceCommandsFromCatalog(ctx context.Context, parent *cobra.Command, f *cmdutil.Factory, catalog apicatalog.Catalog)
RegisterServiceCommandsFromCatalog registers every service of catalog, parsing all of its shards.
Types ¶
type HelpRenderer ¶ added in v1.0.95
type HelpRenderer struct {
// Guidance resolves affordance overlays against the catalog that built the
// tree. nil renders no guidance blocks.
Guidance *affordance.Resolver
// SkillContent returns the skill tree readable through this build's command
// surface, or nil when `skills read` cannot be referenced (which suppresses
// every skill pointer). nil behaves like a nil tree.
SkillContent func() fs.FS
// SkillReferences returns the build's canonical-to-runtime skill projection;
// nil (or a nil result) keeps canonical names and gates them by existence.
SkillReferences func() *skillref.Resolver
// CanReferenceSchema reports whether the `lark-cli schema` pointer may be
// rendered on method help. nil means it may.
CanReferenceSchema func() bool
}
HelpRenderer composes agent guidance into command help for exactly one command tree. It is built once per cmd.Build and holds that build's affordance resolver and skill surface, so help never consults process-global state or another build's catalog. Function fields are evaluated at render time because skill customization is resolved after the help hook is installed.
func (*HelpRenderer) PrepareDomainHelp ¶ added in v1.0.95
func (r *HelpRenderer) PrepareDomainHelp(cmd *cobra.Command) bool
PrepareDomainHelp appends navigational guidance (routing line, risk legend, skill pointers) to a top-level Lark domain's description, returning false for anything that is not such a domain. Built lazily at help time because shortcuts attach after service registration.
A hand-authored Long is preserved as the base (e.g. event's "Use 'event consume <EventKey>'…"); service domains carry only a Short at this point, so we fall back to it. The pristine base is captured once into an annotation so re-rendering does not append the guidance twice.
func (*HelpRenderer) PrepareMethodHelp ¶ added in v1.0.95
func (r *HelpRenderer) PrepareMethodHelp(cmd *cobra.Command) bool
PrepareMethodHelp rebuilds a generated method command's Long with the agent guidance at the TOP (Risk, then the affordance block, then the schema pointer), returning false for non-method commands. The overlay is resolved here — only when help is rendered. Related-skill pointers are emitted only when they resolve in the skill tree (see affordance.SkillStatPath), so a typo or a build without embedded skills never prints a `skills read` that cannot be opened.
func (*HelpRenderer) PrepareShortcutHelp ¶ added in v1.0.95
func (r *HelpRenderer) PrepareShortcutHelp(cmd *cobra.Command) bool
PrepareShortcutHelp composes a +-prefixed shortcut's Long from its affordance overlay — the same top layout as method help (description, Risk, guidance block, related skills) minus the schema pointer, which shortcuts have none of. Returns false when the command is not a shortcut or carries no overlay entry, so shortcuts without guidance keep the default help plus the bottom risk/tips append.
The lead is the command's pristine base (captureHelpBase): a shortcut with a hand-authored Long keeps it, while structured affordance guidance is appended below without clobbering the business description.
Tips precedence (intentional, not a bug): the overlay's ### Tips win. The shortcut's declarative Tips (the Go Tips field) are only a fallback used when the overlay declares none; when the overlay has tips, the Go tips are dropped (replaced, not merged) so tips never render twice. Authoring a ### Tips block therefore silently retires that shortcut's Go Tips — consolidate into one.
type ServiceMethodOptions ¶
type ServiceMethodOptions struct {
Factory *cmdutil.Factory
Cmd *cobra.Command
Ctx context.Context
ServicePath string
Method meta.Method
SchemaPath string
// Flags
Params string
Data string
As core.Identity
Output string
PageAll bool
PageLimit int
PageDelay int
Format string
JqExpr string
DryRun bool
File string // --file flag value
FileFields []string // auto-detected file field names from metadata
// contains filtered or unexported fields
}
ServiceMethodOptions holds all inputs for a dynamically registered service method command.