cmd

package
v0.0.41 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: Apache-2.0 Imports: 46 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package cmd implements the allbctl command-line interface: the root command and every subcommand under it.

Index

Constants

This section is empty.

Variables

View Source
var (
	// Version is the released version of allbctl, or "dev" for local builds.
	Version = "dev"
	// Commit is the git commit allbctl was built from.
	Commit = "unknown"
)

Build metadata, overridden at link time with -ldflags "-X ...".

View Source
var BootstrapCmd = &cobra.Command{
	Use: "bootstrap",
	Aliases: []string{
		"bs",
	},
	Short: "Manage workstation bootstrap configuration",
	Long: `Manage workstation bootstrap configuration including directories, tools, SSH keys, and dotfiles.

Available subcommands:
  status - Check current bootstrap status
  install - Apply bootstrap configuration to setup this machine
  reset - Reset bootstrap configuration`,
	RunE: func(cmd *cobra.Command, _ []string) error {
		return cmd.Help()
	},
}

BootstrapCmd represents the bootstrap command and its subcommands.

View Source
var CloudNativeAWSCmd = &cobra.Command{
	Use:   "aws",
	Short: "Display detailed AWS resource information",
	Long: `Display detailed AWS resource information including:
- CLI version
- Configured profiles
- Resource counts by type and region (only regions with resources are shown)
- Uses AWS Resource Groups Tagging API to discover all resources

Examples:
  allbctl status cloud-native aws                           # All profiles, all regions with resources
  allbctl status cloud-native aws --region us-east-1        # All profiles, specific region
  allbctl status cloud-native aws --profile production      # Specific profile, all regions
  allbctl status cloud-native aws --profile prod --region us-east-1  # Specific profile and region`,
	Run: func(cmd *cobra.Command, _ []string) {
		ctx := commandContext(cmd)
		ctx, span := otel.Tracer("github.com/aallbrig/allbctl").Start(ctx, "status.cloud-native.aws")
		defer span.End()
		printAWSDetails(ctx, awsQuery{Profile: profileFlag, Region: regionFlag})
	},
}

CloudNativeAWSCmd represents the AWS-specific command

View Source
var CloudNativeAzureCmd = &cobra.Command{
	Use:   "azure",
	Short: "Display detailed Azure resource information",
	Long:  `Display detailed Azure resource information (implementation pending).`,
	Run: func(_ *cobra.Command, _ []string) {
		fmt.Println("Azure detailed view: implementation todo")
	},
}

CloudNativeAzureCmd represents the Azure-specific command

View Source
var CloudNativeCmd = &cobra.Command{
	Use:     "cloud-native",
	Aliases: []string{"cloud_native", "cn"},
	Short:   "Display cloud CLI information and resources",
	Long: `Display cloud CLI versions and resource information for AWS, GCP, Azure, and Kubernetes.

This command shows:
- CLI version for each detected cloud provider
- Number of configured profiles/users
- Resource counts by region (when detailed subcommands are used)

Examples:
  allbctl status cloud-native          # Show summary for all detected cloud CLIs
  allbctl status cn                    # Short alias
  allbctl status cloud-native aws      # Show detailed AWS resource info
  allbctl status cn aws --region us-east-1  # AWS resources in specific region`,
	Run: func(cmd *cobra.Command, _ []string) {
		ctx := commandContext(cmd)
		ctx, span := otel.Tracer("github.com/aallbrig/allbctl").Start(ctx, "status.cloud-native")
		defer span.End()
		printCloudNativeSummary(ctx)
	},
}

CloudNativeCmd represents the cloud-native command

View Source
var CloudNativeGCPCmd = &cobra.Command{
	Use:   "gcp",
	Short: "Display detailed GCP resource information",
	Long:  `Display detailed GCP resource information (implementation pending).`,
	Run: func(_ *cobra.Command, _ []string) {
		fmt.Println("GCP detailed view: implementation todo")
	},
}

CloudNativeGCPCmd represents the GCP-specific command

View Source
var CloudNativeK8sCmd = &cobra.Command{
	Use:     "kubernetes",
	Aliases: []string{"k8s"},
	Short:   "Display detailed Kubernetes resource information",
	Long:    `Display detailed Kubernetes resource information (implementation pending).`,
	Run: func(_ *cobra.Command, _ []string) {
		fmt.Println("Kubernetes detailed view: implementation todo")
	},
}

CloudNativeK8sCmd represents the Kubernetes-specific command

View Source
var ContainersCmd = &cobra.Command{
	Use:   "containers",
	Short: "Display container and virtualization information",
	Long:  `Display information about containers (Docker, Podman) and virtualization status.`,
	Run: func(cmd *cobra.Command, _ []string) {
		ctx := commandContext(cmd)
		ctx, span := otel.Tracer("github.com/aallbrig/allbctl").Start(ctx, "status.containers")
		defer span.End()
		PrintContainersInfo(ctx)
	},
}

ContainersCmd prints container runtime and virtualization status.

View Source
var DbCmd = &cobra.Command{
	Use:   "db [database]",
	Short: "Display detected databases and their information",
	Long: `Display detected database management systems (DBMS) and their information.

Shows database clients, versions, running status, and database files.

Examples:
  allbctl status db                  # Show all detected databases
  allbctl status db sqlite3          # Show only SQLite3 info
  allbctl status db postgres         # Show only PostgreSQL info
  allbctl status db --detail         # Show detailed info for all databases
  allbctl status db sqlite3 --detail # Show detailed SQLite3 info with .db files`,
	Run: func(cmd *cobra.Command, args []string) {
		ctx := commandContext(cmd)
		ctx, span := otel.Tracer("github.com/aallbrig/allbctl").Start(ctx, "status.db")
		defer span.End()

		if len(args) > 0 {
			dbName := args[0]
			showDatabaseInfo(ctx, dbName, dbDetailFlag)
			telemetry.Logger.InfoContext(ctx, "status.db",
				"database", dbName,
				"detail", dbDetailFlag,
			)
			span.SetAttributes(attribute.String("db.filter", dbName))
			return
		}

		detected := detectAllDatabases(ctx)
		fmt.Print(formatAllDatabases(detected, dbDetailFlag))

		detectedNames := databaseNames(detected)
		telemetry.Logger.InfoContext(ctx, "status.db",
			"detected_count", len(detectedNames),
			"databases", detectedNames,
			"detail", dbDetailFlag,
		)
		span.SetAttributes(
			attribute.Int("db.detected_count", len(detectedNames)),
			attribute.StringSlice("db.databases", detectedNames),
		)
	},
}

DbCmd represents the db command

View Source
var GitConfigCmd = &cobra.Command{
	Use:   "git",
	Short: "Display git global configuration",
	Long:  `Display git global configuration including user name, email, and editor.`,
	Run: func(cmd *cobra.Command, _ []string) {
		ctx := commandContext(cmd)
		ctx, span := otel.Tracer("github.com/aallbrig/allbctl").Start(ctx, "status.git")
		defer span.End()
		PrintGitConfigInfo(ctx)
	},
}

GitConfigCmd prints the identity and editor from the global git config.

View Source
var ListPackagesCmd = &cobra.Command{
	Use:   "list-packages [package-manager]",
	Short: "Show package count summary from all detected package managers",
	Long: `Show package count summary from all detected package managers.

By default, shows the same summary as the 'Packages:' section in 'allbctl status'.

For system package managers (apt, yum, brew, chocolatey, etc.), only explicitly
installed packages are counted, not their dependencies.

For programming runtime package managers (npm, pip, gem, etc.), only globally
installed packages are counted.

If a package manager is not detected on the system, it will not be displayed.

Use --detail flag to see the full list of all installed packages.

You can also specify a specific package manager to list only its packages:
  allbctl list-packages apt
  allbctl list-packages npm
  allbctl list-packages flatpak`,
	Run: func(cmd *cobra.Command, args []string) {
		ctx, span := otel.Tracer(tracerName).Start(commandContext(cmd), "status.list-packages")
		defer span.End()
		listInstalledPackages(ctx, args)
	},
}

ListPackagesCmd represents the list-packages command

View Source
var NetworkCmd = &cobra.Command{
	Use:   "network",
	Short: "Display network interface information",
	Long: `Display network interface information including IP addresses, router, connection type, VPN status, DNS, and connectivity.

This is the same output shown in the 'Network:' section of 'allbctl status'.`,
	Run: func(cmd *cobra.Command, _ []string) {
		ctx := commandContext(cmd)
		ctx, span := otel.Tracer("github.com/aallbrig/allbctl").Start(ctx, "status.network")
		defer span.End()
		PrintNetworkInfo(ctx)
	},
}

NetworkCmd prints the network section of `allbctl status` on its own.

View Source
var PortsCmd = &cobra.Command{
	Use:   "ports",
	Short: "Display listening ports",
	Long:  `Display count of listening TCP/UDP ports and details about what's listening.`,
	Run: func(cmd *cobra.Command, _ []string) {
		ctx := commandContext(cmd)
		ctx, span := otel.Tracer("github.com/aallbrig/allbctl").Start(ctx, "status.ports")
		defer span.End()
		PrintPortsInfo(ctx)
	},
}

PortsCmd prints the listening TCP/UDP ports and what owns them.

View Source
var ProjectsCmd = &cobra.Command{
	Use:   "projects",
	Short: "Display git repositories in ~/src",
	Long: `Display a summary of git repositories found in ~/src directory.

By default, shows the same summary as the 'Projects:' section in 'allbctl status'.
Dirty repos are marked with an asterisk (*).

Examples:
  allbctl status projects                        # Show summary (default, same as status)
  allbctl status projects --all                  # Show all repos
  allbctl status projects --dirty                # Show only dirty repos
  allbctl status projects --clean                # Show only clean repos
  allbctl status projects --dirty -v             # Show dirty repos with their changed files
  allbctl status projects --all --languages      # Show all repos with language breakdown
  allbctl status projects -v --languages=false   # Verbose without language breakdown`,
	Run: func(cmd *cobra.Command, _ []string) {
		ctx, span := otel.Tracer(tracerName).Start(commandContext(cmd), "status.projects")
		defer span.End()

		langExplicit := cmd.Flags().Changed("languages")
		showLanguages = languagesFlag && (verboseFlag || langExplicit)

		switch {
		case allFlag || dirtyFlag || cleanFlag || verboseFlag || (langExplicit && languagesFlag):
			printProjectsSummary(ctx)

		case !printProjectsInline(ctx, limitFlag):

			fmt.Println("Projects: no git repositories found in ~/src")
		}

		telemetry.Logger.InfoContext(ctx, "status.projects",
			"all", allFlag,
			"dirty", dirtyFlag,
			"clean", cleanFlag,
			"verbose", verboseFlag,
			"limit", limitFlag,
		)
	},
}

ProjectsCmd represents the projects command

View Source
var RuntimesCmd = &cobra.Command{
	Use:   "runtimes",
	Short: "Display detected runtimes and their versions",
	Long: `Display detected programming language runtimes and their versions.

This is the same output shown in the 'Runtimes:' section of 'allbctl status'.`,
	Run: func(cmd *cobra.Command, _ []string) {
		ctx, span := otel.Tracer(tracerName).Start(commandContext(cmd), "status.runtimes")
		defer span.End()
		PrintRuntimes(ctx)
	},
}

RuntimesCmd represents the `status runtimes` command.

View Source
var SecurityCmd = &cobra.Command{
	Use:   "security",
	Short: "Display security and authentication status",
	Long:  `Display information about SSH keys, GPG keys, and kernel keyring.`,
	Run: func(cmd *cobra.Command, _ []string) {
		ctx := commandContext(cmd)
		ctx, span := otel.Tracer("github.com/aallbrig/allbctl").Start(ctx, "status.security")
		defer span.End()
		PrintSecurityInfo(ctx)
	},
}

SecurityCmd prints the SSH, GPG and kernel-keyring key inventory.

View Source
var StatusCmd = &cobra.Command{
	Use:   "status",
	Short: "Display system information (like neofetch)",
	Run: func(cmd *cobra.Command, _ []string) {
		ctx := commandContext(cmd)
		ctx, span := otel.Tracer("github.com/aallbrig/allbctl").Start(ctx, "status.printSystemInfo",
			trace.WithAttributes(attribute.String("command", "status")),
		)
		defer span.End()
		printSystemInfo(ctx)
	},
}

StatusCmd represents status command

View Source
var SystemctlCmd = &cobra.Command{
	Use:   "systemctl",
	Short: "Display systemd service status",
	Long:  `Display count of running system and user services, and any failed services.`,
	Run: func(cmd *cobra.Command, _ []string) {
		ctx := commandContext(cmd)
		ctx, span := otel.Tracer("github.com/aallbrig/allbctl").Start(ctx, "status.systemctl")
		defer span.End()
		PrintSystemctlInfo(ctx)
	},
}

SystemctlCmd prints running and failed systemd service counts.

View Source
var UpdateCmd = &cobra.Command{
	Use:   subcommandUpdate,
	Short: "Update and upgrade all detected package managers",
	Long: `Update and upgrade packages from all detected package managers on the system.

Runs update/upgrade commands for each detected package manager sequentially.
Some managers require sudo and will prompt for your password.

Supported managers: apt, flatpak, snap, dnf, yum, pacman, brew, choco, winget, npm, pipx, gem

Intentionally skipped:
  pip   - Risky to auto-upgrade all pip packages (can break system Python)
  cargo - No global upgrade mechanism
  go    - No global upgrade mechanism

Use --dry-run to preview what commands would be executed.
Use --managers to limit which package managers are updated.

Examples:
  allbctl update                    # Update everything detected
  allbctl update --dry-run          # Preview what would happen
  allbctl update --managers apt,npm # Only update apt and npm`,
	Aliases: []string{"up", subcommandUpgrade},
	Run: func(cmd *cobra.Command, _ []string) {

		ctx, stop := signal.NotifyContext(commandContext(cmd), os.Interrupt)
		defer stop()
		runUpdate(ctx)
	},
}

UpdateCmd represents the update command

Functions

func Execute

func Execute()

Execute runs the root command and exits non-zero when it fails.

cobra has already reported the error on stderr by the time Execute returns, so it is not printed again here.

func PrintContainersInfo added in v0.0.26

func PrintContainersInfo(ctx context.Context)

PrintContainersInfo prints Docker and Podman usage and whether the host is virtualized.

func PrintDatabaseSummaryForStatus added in v0.0.22

func PrintDatabaseSummaryForStatus(ctx context.Context)

PrintDatabaseSummaryForStatus prints a one-line summary for the main status command

func PrintGitConfigInfo added in v0.0.26

func PrintGitConfigInfo(ctx context.Context)

PrintGitConfigInfo prints the global git identity and editor, or a one-line notice when git is not installed.

func PrintNetworkInfo added in v0.0.25

func PrintNetworkInfo(ctx context.Context)

PrintNetworkInfo outputs comprehensive network information

func PrintPortsInfo added in v0.0.26

func PrintPortsInfo(ctx context.Context)

PrintPortsInfo prints the listening-port counts followed by one line per listener.

func PrintRuntimes added in v0.0.21

func PrintRuntimes(ctx context.Context)

PrintRuntimes outputs the runtimes in inline format (same as status command)

func PrintSecurityInfo added in v0.0.26

func PrintSecurityInfo(ctx context.Context)

PrintSecurityInfo prints the keys loaded in the SSH agent, the GPG public keys and, on Linux, the user keyring summary.

func PrintSystemctlInfo added in v0.0.26

func PrintSystemctlInfo(ctx context.Context)

PrintSystemctlInfo prints the systemd service counts, or a one-line explanation when systemd is not available on this host.

Types

type AIAgent added in v0.0.14

type AIAgent struct {
	Name    string
	Version string
}

AIAgent represents an AI coding assistant

type AWSResourceCount added in v0.0.28

type AWSResourceCount struct {
	ResourceType string
	Count        int64
}

AWSResourceCount holds resource count information

type BrowserInfo added in v0.0.18

type BrowserInfo struct {
	Name    string
	Version string
}

BrowserInfo holds browser information

type CICheck added in v0.0.35

type CICheck struct {
	Name       string `json:"name"`
	Conclusion string `json:"conclusion"`
}

CICheck represents a single GitHub check run with its name and conclusion.

type CPUDetails added in v0.0.18

type CPUDetails struct {
	ModelName      string
	Architecture   string
	Cores          int
	ThreadsPerCore int
	CoresPerSocket int
	Sockets        int
	PhysicalCores  int
	LogicalCores   int
	BaseClock      string
	PCores         int
	ECores         int
	HasPECores     bool
}

CPUDetails holds detailed CPU information

type CloudCLIInfo added in v0.0.28

type CloudCLIInfo struct {
	Name             string
	Version          string
	KustomizeVersion string // For kubectl
	ProfileCount     int
	// Profiles are account names, emails or cluster contexts. They can
	// identify an account, so only their count is ever displayed.
	Profiles  []string
	Connected bool
}

CloudCLIInfo holds information about a cloud CLI

type ContainerInfo added in v0.0.26

type ContainerInfo struct {
	Runtime     string
	Running     int
	Images      int
	ImagesList  []string
	Virtualized bool
	VirtType    string
}

ContainerInfo describes one container runtime, or (for the virtualization check) whether the host itself is a guest.

type DatabaseInfo added in v0.0.22

type DatabaseInfo struct {
	Name          string
	ClientBinary  string
	ServerBinary  string
	ClientVersion string
	ServerVersion string
	IsRunning     bool
	DatabaseFiles []string
	// EnvVars holds raw values; redact them before display.
	EnvVars       map[string]string
	OtherBinaries []string
}

DatabaseInfo describes one database system found on the host.

type DirtyReason added in v0.0.32

type DirtyReason uint

DirtyReason is a bitmask describing why a repo is considered dirty

const (
	DirtyUncommittedChanges DirtyReason = 1 << iota // has staged, unstaged, or untracked changes
	DirtyUnpushedCommits                            // has commits not yet pushed to upstream
	DirtyNoUpstream                                 // current branch has no remote tracking branch
	DirtyCIFailed                                   // remote CI has a failed check on this branch
	DirtyCIPending                                  // remote CI has an in-progress check on this branch
)

The reasons a repository can be dirty; a repo may have several at once.

func (DirtyReason) Labels added in v0.0.32

func (r DirtyReason) Labels() []string

Labels returns a human-readable label for every reason set in r.

func (DirtyReason) String added in v0.0.32

func (r DirtyReason) String() string

type DiskInfo added in v0.0.27

type DiskInfo struct {
	Device      string
	Mountpoint  string
	Filesystem  string
	Total       uint64
	Used        uint64
	Free        uint64
	UsedPercent float64
}

DiskInfo holds detailed disk information

type GPUInfo added in v0.0.18

type GPUInfo struct {
	Name          string
	Vendor        string
	Memory        string
	Driver        string
	ComputeCap    string
	ClockGraphics string
	ClockMemory   string
}

GPUInfo holds detailed GPU information

type GitConfigInfo added in v0.0.26

type GitConfigInfo struct {
	UserName   string
	UserEmail  string
	CoreEditor string
}

GitConfigInfo holds the global git settings `status git` reports. A field is empty when the setting is not configured.

type InterfaceInfo added in v0.0.25

type InterfaceInfo struct {
	Name       string
	IP         string
	Status     string
	IsVPN      bool
	IsLoopback bool
	Gateway    string
}

InterfaceInfo holds interface details

type NetworkDetails added in v0.0.25

type NetworkDetails struct {
	Interfaces     []InterfaceInfo
	VPNActive      bool
	VPNInterface   *InterfaceInfo
	PrimaryIface   *InterfaceInfo
	DefaultGateway string
	DNSServers     []string
	VPNDNSServers  []string
	PublicIP       string
	InternetOK     bool
	WiFiDetails    *WiFiInfo
}

NetworkDetails holds comprehensive network information

type PackageResult added in v0.0.27

type PackageResult struct {
	Manager     string
	Count       int
	UpdateCount int
	Index       int
}

PackageResult holds package count results for a single package manager

type PackageSummaryFuture added in v0.0.27

type PackageSummaryFuture struct {
	// contains filtered or unexported fields
}

PackageSummaryFuture represents an ongoing package detection operation

func (*PackageSummaryFuture) PrintResults added in v0.0.27

func (f *PackageSummaryFuture) PrintResults()

PrintResults waits for all package detection to complete and prints the results

type PortInfo added in v0.0.26

type PortInfo struct {
	TCPPorts int
	UDPPorts int
	// Ports holds one display line per listener, e.g. "tcp:22 (sshd)".
	Ports []string
}

PortInfo is the set of listening sockets found on the host.

type RepoInfo added in v0.0.15

type RepoInfo struct {
	Path             string
	ModTime          time.Time
	Dirty            bool
	DirtyReasons     DirtyReason
	RemoteRepo       string                        // e.g., "aallbrig/allbctl" or "godotengine/godot"
	StatusOutput     string                        // populated when -v/--verbose is set; full `git status --untracked-files=all` output
	UncommittedFiles int                           // staged + unstaged file count (excludes untracked)
	UntrackedFiles   int                           // untracked file count
	UnpushedCommits  int                           // number of commits ahead of upstream
	CIStatus         string                        // "success", "failure", "pending", or "" (no CI detected)
	CIChecks         []CICheck                     // populated when -v/--verbose is set
	Languages        []languages.LanguageBreakdown // populated when -v/--verbose is set
}

RepoInfo contains information about a git repository

type RuntimeCheck added in v0.0.13

type RuntimeCheck struct {
	Command  []string
	Category string
}

RuntimeCheck is the command that prints a runtime's version, and the category the runtime is displayed under.

type RuntimeInfo added in v0.0.13

type RuntimeInfo struct {
	Name     string
	Version  string
	Category string
}

RuntimeInfo is a runtime that was found on this machine.

type SecurityInfo added in v0.0.26

type SecurityInfo struct {
	// SSHKeys has one "bits fingerprint comment" line per agent identity.
	SSHKeys []string
	// GPGKeys has one "algo/keyid - uid" line per public key.
	GPGKeys []string
	// KeyringInfo summarizes the Linux user keyring; empty when it has no keys.
	KeyringInfo string
}

SecurityInfo lists the public identifiers of the keys available to the user. It never holds private key material.

type SystemctlInfo added in v0.0.26

type SystemctlInfo struct {
	SystemRunning int
	SystemFailed  int
	UserRunning   int
	UserFailed    int
}

SystemctlInfo holds service counts for the system manager and for the current user's manager.

type UpdateInfo added in v0.0.25

type UpdateInfo struct {
	Current   string
	Available string
	IsLTS     bool
}

UpdateInfo holds information about available updates

type WiFiInfo added in v0.0.25

type WiFiInfo struct {
	SSID      string
	Frequency string
	Standard  string
	Signal    string
	Quality   string
	Speed     string
}

WiFiInfo holds WiFi-specific details

Jump to

Keyboard shortcuts

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