completion

package
v0.0.0-...-68956d0 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package completion generates shell tab-completion scripts for gitmap.

dynamic.go — context-aware tab-completion helper (#14).

Shells invoke `gitmap __complete <cword> <args...>` and read newline-separated suggestions from stdout. The static command list (allcommands_generated.go) is widened with:

  • repo path completions for cd/clone/reclone-class commands (directories under cwd that look like a git repo).
  • profile-name completions for chrome-profile-* commands (sourced from Chrome `Local State`, falling back to dir names).
  • version completions for visibility / make-* / find-next (sourced from the OwnerRepoNameIndex SQLite table when present).

The runtime helper is intentionally I/O-light: each branch returns in O(few dozen filesystem entries) so completion stays snappy.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllCommands

func AllCommands() []string

AllCommands returns every command name and alias offered by tab-completion.

The list is the union of generatedCommands (auto-extracted from the constants package by internal/gencommands) and manualExtras. Run `go generate ./completion/...` after adding new Cmd* constants to refresh the generated portion.

func DetectShell

func DetectShell() string

DetectShell returns the current shell type based on environment.

func Dynamic

func Dynamic(cword int, argv []string) []string

Dynamic returns suggestions for the given argv slice. `cword` is the index of the word being completed (0-based, excluding the `gitmap` binary itself). When no specialized handler matches it falls back to the static command list filtered by prefix.

func Generate

func Generate(shell string) (string, error)

Generate returns the completion script for the given shell.

func Install

func Install(shell string) error

Install writes the completion script and adds a source line to the profile.

func InstallCDFunction

func InstallCDFunction(shell string) error

InstallCDFunction writes the gitmap/gcd shell wrapper to user profiles.

func WriteDynamic

func WriteDynamic(w io.Writer, cword int, argv []string)

WriteDynamic writes Dynamic(cword, argv) suggestions to w as newline-separated values. Intended for `gitmap __complete` glue.

Types

This section is empty.

Directories

Path Synopsis
internal
gencommands command
Command gencommands generates allcommands_generated.go by extracting every Cmd* string constant from constants files in the sibling constants/ package that have explicitly opted into completion via marker comments.
Command gencommands generates allcommands_generated.go by extracting every Cmd* string constant from constants files in the sibling constants/ package that have explicitly opted into completion via marker comments.

Jump to

Keyboard shortcuts

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