Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var BrewCmd = &cobra.Command{ Use: "brew", Short: "Update Homebrew packages only", Long: `This command updates only Homebrew packages, skipping system updates.`, Run: func(cmd *cobra.Command, _args []string) { isVerbose := cmdutil.IsVerbose(cmd) updateBrew(isVerbose) }, }
BrewCmd represents the Homebrew update subcommand.
View Source
var CompauditFixCmd = &cobra.Command{ Use: "compauditFix", Short: "Fix insecure directories reported by compaudit", Long: `Runs 'compaudit' and applies 'chmod g-w,o-w' to any directories reported as insecure. This uses an interactive zsh so zsh functions like compaudit (from oh-my-zsh) are available.`, Run: func(cmd *cobra.Command, _args []string) { log.Start("Running compaudit and fixing insecure directories...") isVerbose := cmdutil.IsVerbose(cmd) execCmd := exec.Command("zsh", "-ic", "compaudit | xargs --no-run-if-empty chmod g-w,o-w") log.Verbose(isVerbose, "Executing: %s", execCmd.String()) outputBytes, err := execCmd.CombinedOutput() output := strings.TrimSpace(string(outputBytes)) if err != nil { log.Error("Failed to run compaudit fix: %v", err) if output != "" { log.Error("Output: %s", output) } return } if output != "" { log.Message("%s", output) } log.Success("Finished applying compaudit fixes.") }, }
CompauditFixCmd runs 'compaudit' and removes group/world write permissions from any reported insecure directories.
View Source
var KillPortCmd = &cobra.Command{ Use: "killPort [port]", Short: "Find and kill the process listening on a specific port", Long: `This command finds the process ID (PID) listening on the specified network port using available tools (lsof, ss, netstat) and then terminates that process. A comma-separated list of ports may be provided to kill processes on multiple ports, e.g. "eng system killPort 3000,8080". If no port is provided or --interactive is used, it lists listening ports for selection. Requires appropriate tools to be available on the system. Primarily intended for Unix-like systems (Linux, macOS).`, Args: cobra.MaximumNArgs(1), Run: func(cmd *cobra.Command, args []string) { isVerbose := cmdutil.IsVerbose(cmd) var portList []string if len(args) == 0 || interactive { log.Message("Listing listening ports...") ports, err := listPorts(filter) if err != nil { log.Error("Failed to list ports: %v", err) return } if len(ports) == 0 { log.Warn("No listening ports found.") return } selectedPort, err := selectPort(ports) if err != nil { log.Error("Failed to select port: %v", err) return } portList = []string{selectedPort.Port} } else { log.Message("Parsing ports: %s", args[0]) var errs []error portList, errs = parsePortList(args[0]) if len(errs) > 0 { log.Error("Found %d problem(s) in port list %q:", len(errs), args[0]) for _, err := range errs { log.Error(" - %v", err) } return } } for _, portStr := range portList { killPort(portStr, signal, isVerbose) } }, }
View Source
var KillProcessCmd = &cobra.Command{ Use: "killProcess [pid]", Short: "Find and kill a process by PID or interactively", Long: `This command finds and kills a process by its PID, or lists processes for interactive selection. If no PID is provided or --interactive is used, it lists running processes for selection. Requires 'ps' and 'kill' commands to be available on the system. Primarily intended for Unix-like systems (Linux, macOS).`, Args: cobra.MaximumNArgs(1), Run: func(cmd *cobra.Command, args []string) { isVerbose := cmdutil.IsVerbose(cmd) var pidStr string var selectedProcess ProcessInfo if len(args) == 0 || processInteractive { log.Message("Listing running processes...") processes, err := listProcesses(processFilter) if err != nil { log.Error("Failed to list processes: %v", err) return } if len(processes) == 0 { log.Warn("No processes found.") return } selectedProcess, err = selectProcess(processes) if err != nil { log.Error("Failed to select process: %v", err) return } pidStr = selectedProcess.PID } else { pidStr = args[0] if _, err := strconv.Atoi(pidStr); err != nil { log.Error("Invalid PID provided: %s. PID must be an integer.", pidStr) return } } log.Message("Attempting to kill process with PID %s...", pidStr) killCmd := exec.Command("kill", "-"+processSignal, pidStr) log.Verbose(isVerbose, "Executing: %s", killCmd.String()) if err := killCmd.Run(); err != nil { log.Error("Failed to kill process with PID %s: %v", pidStr, err) if strings.Contains(err.Error(), "permission denied") { log.Warn("Try running with sudo: sudo kill -%s %s", processSignal, pidStr) } } else { log.Success("Successfully sent kill signal %s to process with PID %s.", processSignal, pidStr) } }, }
View Source
var ProxyCmd = &cobra.Command{ Use: "proxy", Short: "Show or configure system proxies", Long: `Display, switch, test, and manage multiple proxy configurations with rich visual feedback.`, Run: func(cmd *cobra.Command, args []string) { listProxyConfigurations(cmd) }, }
View Source
var SetupASDFCmd = &cobra.Command{ Use: "asdf", Short: "Setup asdf plugins from $HOME/.tool-versions", Long: `Reads $HOME/.tool-versions and installs asdf plugins listed there.`, Run: func(cmd *cobra.Command, args []string) { setupASDF(cmdutil.IsVerbose(cmd)) }, }
View Source
var SetupCmd = &cobra.Command{ Use: "setup", Short: "Setup development tools", Long: `Setup various development tools. Running this command without subcommands will run all setup steps: - Oh My Zsh - ASDF plugins - Dotfiles installation - Dotfiles secrets restore (when configured) - Software installation - GPG keys setup (interactive) - GPG permissions fix`, RunE: func(cmd *cobra.Command, _args []string) error { if err := runSetup(cmd, cmdutil.IsVerbose(cmd)); err != nil { return fmt.Errorf("setup failed: %w", err) } return nil }, }
View Source
var SetupDotfilesCmd = &cobra.Command{ Use: "dotfiles", Short: "Setup dotfiles from your git repository", Long: `Setup dotfiles from your git repository. This command will: - Check and install prerequisites (Homebrew, Git, Bash) - Setup SSH keys for GitHub when required by the repository URL - Clone your dotfiles repository as a bare repository - Backup any conflicting files - Checkout dotfiles to your home directory - Initialize git submodules - Configure git to hide untracked files - Restore dotfiles secrets when manifest and BWS token are available`, RunE: func(cmd *cobra.Command, args []string) error { if err := setupDotfiles(cmdutil.IsVerbose(cmd)); err != nil { return fmt.Errorf("dotfiles setup failed: %w", err) } return nil }, }
View Source
var SetupGPGCmd = &cobra.Command{ Use: "gpg", Short: "Setup GPG keys for signing and encryption", Long: `Setup GPG keys for signing commits and encryption. This command will: - Prompt you for GPG key files to import - Import master key and subkeys - Set ultimate trust on the key - Configure Git to use your GPG key for signing - Optionally remove the master key (keeping only subkeys for security)`, RunE: func(cmd *cobra.Command, args []string) error { if err := setupGPG(cmdutil.IsVerbose(cmd)); err != nil { return fmt.Errorf("gpg setup failed: %w", err) } return nil }, }
View Source
var SetupOhMyZshCmd = &cobra.Command{ Use: "oh-my-zsh", Short: "Install Oh My Zsh", Long: `Downloads and installs Oh My Zsh. Skips if already installed.`, Run: func(cmd *cobra.Command, args []string) { setupOhMyZsh(cmdutil.IsVerbose(cmd)) }, }
View Source
var SetupSSHCmd = &cobra.Command{ Use: "ssh", Short: "Setup SSH keys for GitHub access", Long: `Setup SSH keys for GitHub access. This command will: - Check for existing SSH keys - Attempt to retrieve SSH keys from Bitwarden vault - Generate new SSH keys if none found - Configure SSH config for GitHub`, RunE: func(cmd *cobra.Command, args []string) error { if err := setupSSH(cmdutil.IsVerbose(cmd)); err != nil { return fmt.Errorf("ssh setup failed: %w", err) } return nil }, }
View Source
var SystemCmd = &cobra.Command{ Use: "system", Short: "A command for managing the system", Long: `This command will help manage various aspects of MacOS and Linux systems.`, Run: func(cmd *cobra.Command, _args []string) { err := cmd.Help() cobra.CheckErr(err) }, }
View Source
var UpdateCmd = &cobra.Command{ Use: "update", Aliases: []string{"update", "u"}, Short: "Update the system and perform maintenance", Long: `This command updates the system, Homebrew packages, asdf plugins, and performs cleanup operations.`, Run: func(cmd *cobra.Command, _args []string) { headerStyle := lipgloss.NewStyle(). Bold(true). Foreground(theme.Primary). MarginBottom(1) if !ui.DisableProgress { fmt.Println(headerStyle.Render("🚀 System Maintenance & Update")) } isVerbose := cmdutil.IsVerbose(cmd) autoApprove, _ := cmd.Flags().GetBool("yes") cleanupTimeout, _ := cmd.Flags().GetInt("cleanup-timeout") log.Verbose(isVerbose, "Checking system type...") checkCmd := execCommand("uname", "-a") output, err := checkCmd.Output() if err != nil { log.Error("Error checking system type: %s", err) return } uname := strings.ToLower(string(output)) log.Verbose(isVerbose, "System type detected: %s", strings.TrimSpace(string(output))) if strings.Contains(uname, "ubuntu") || strings.Contains(uname, "linux") { log.Verbose(isVerbose, "Detected Ubuntu/Linux system, running system update...") updateUbuntu(isVerbose, autoApprove, cleanupTimeout) } else if strings.Contains(uname, "darwin") { log.Verbose(isVerbose, "Detected macOS system, running macOS update...") updateMacOS(isVerbose) } else if strings.Contains(uname, "raspberrypi") || strings.Contains(uname, "raspbian") { log.Verbose(isVerbose, "Detected Raspberry Pi system, running Raspberry Pi update...") updateRaspberryPi(isVerbose) } else { log.Warn("This system is not yet supported for updates.") log.Verbose(isVerbose, "Unsupported system type: %s", strings.TrimSpace(string(output))) } }, }
UpdateCmd represents the system update command.
Functions ¶
func EnsurePrerequisites ¶ added in v0.28.0
EnsurePrerequisites checks and installs core prerequisites needed for setup flows. SSH is handled contextually by callers that need GitHub access.
func SetupSSHForGitHub ¶ added in v1.9.0
SetupSSHForGitHub exposes the SSH setup flow for other commands that need GitHub access.
Types ¶
type ProcessInfo ¶ added in v0.31.0
type Software ¶ added in v0.29.0
type Software struct {
Name string
Description string
Optional bool
URL string // For manual downloads
Check func() bool // Returns true if already installed
// Install returns an error if installation fails.
// For manual installs, this typically involves opening a URL.
Install func() error
// OS restriction (empty means both, otherwise "linux" or "darwin")
OS string
}
Click to show internal directories.
Click to hide internal directories.