cmd

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 20, 2026 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const CompletionCacheTTL = 10 * time.Second

CompletionCacheTTL bounds how long a live-DB completion result is reused from carapace's on-disk cache before the teamclient is queried again. Deliberately short: it collapses the per-keystroke query storm of exec-once CLI mode — where every Tab reconnects and re-fetches (and re-formats) the whole object set with no server-side prefix match or cap (see cmd/aims/BENCH_COMPLETIONS.md) — into roughly one query per typing burst, while keeping candidates fresh. The cached snapshot is client-side, so a change made by another operator, or by a server-side scan, is invisible until the TTL lapses (or until a local mutation bumps the epoch — see InvalidateCompletionCache).

Variables

This section is empty.

Functions

func BindFlags

func BindFlags(name string, persistent bool, cmd *cobra.Command, flags func(f *pflag.FlagSet))

BindFlags is a convenience function to bind flags to a given command. name - The name of the flag set (can be empty). cmd - The command to which the flags should be bound. flags - A function exposing the flag set through which flags are declared.

func BindGroup

func BindGroup(group string, menu *cobra.Command, con *client.Client, cmds ...func(con *client.Client) *cobra.Command)

BindGroup is a helper used to bind a list of root commands to a given menu, for a given "command help group". @group - Name of the group under which the command should be shown. Preferably use a string in the constants package. @menu - The command menu to which the commands should be bound (either server or implant menu). @ cmds - A list of functions returning a list of root commands to bind. See any package's `commands.go` file and function.

func CacheCompletion

func CacheCompletion(con *client.Client, name string, action carapace.Action) carapace.Action

CacheCompletion wraps a live-DB completion action with carapace's on-disk cache. carapace still filters the cached full candidate set against what the user typed, so caching the whole set (which these completions already fetch) is correct: fetch once, filter many. The cache is namespaced by three keys:

  • scope — the teamserver identity, so a multiplayer client never serves one server's objects when completing against another (see Client.CompletionScope);
  • name — so distinct completions don't collide, since they share this wrapper's call site (carapace derives the cache directory from the call site);
  • epoch — the local mutation sentinel, so an add/import invalidates the cache immediately rather than after the TTL (see completionEpochKey).

Only callback actions are cached; a failed connection returns an ActionMessage and is not cached.

func CheckError

func CheckError(err error) error

CheckError tries to unwrap an error, assuming its a gRPC error.

func CompleteFlags

func CompleteFlags(cmd *cobra.Command, bind func(comp *carapace.ActionMap))

CompleteFlags is a convenience function for adding completions to a command's flags. cmd - The command owning the flags to complete. bind - A function exposing a map["flag-name"]carapace.Action.

func InvalidateCompletionCache

func InvalidateCompletionCache() error

InvalidateCompletionCache bumps the completion epoch so every on-disk completion cache (see CacheCompletion) is treated as stale on the next Tab. Call it after a command successfully mutates the database (add / import / any Create/Upsert) so completions reflect the change immediately instead of after CompletionCacheTTL. Best-effort: an error only means completions stay cached until the TTL lapses.

func MatchesAnyPrefix

func MatchesAnyPrefix(id string, prefixes []string) bool

MatchesAnyPrefix reports whether id has any of the (ANSI-stripped) prefixes. With no prefixes it returns false; callers that want "no filter = match all" test len(args) first.

func StripANSI

func StripANSI(str string) string

StripANSI removes all ANSI escaped color sequences from a string. It is the shared spelling of the per-package helper that every CLI subtree used to redefine identically.

Types

This section is empty.

Directories

Path Synopsis
shell
Package shell is the boundary between AIMS and the operator's interactive shell for the `bring` implant-context feature (see BRING.md).
Package shell is the boundary between AIMS and the operator's interactive shell for the `bring` implant-context feature (see BRING.md).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL