Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HasHomebrew ¶
func HasHomebrew() bool
HasHomebrew checks if Homebrew is installed on the user's system.
This function determines the presence of Homebrew by looking for the "brew" executable in the system's PATH. It is useful to ensure Homebrew dependencies can be managed before executing related commands.
Returns:
- A boolean value indicating whether Homebrew is installed.
func IsCI ¶
func IsCI() bool
IsCI checks if the code is running in a Continuous Integration (CI) environment.
This function checks for common environment variables used by popular CI systems like GitHub Actions, Travis CI, CircleCI, Jenkins, TeamCity, and others.
Returns:
- A boolean value indicating whether the code is running in a CI environment.
func IsColorDisabled ¶
func IsColorDisabled() bool
IsColorDisabled checks if color output is disabled based on the environment settings.
This function uses the `termenv` library to determine if the NO_COLOR environment variable is set, which is a common way to disable colored output.
Returns:
- A boolean value indicating whether color output is disabled.
func IsTTY ¶
func IsTTY() bool
IsTTY checks if the current output is a TTY (teletypewriter) or a Cygwin terminal.
This function is useful for determining if the program is running in a terminal environment, which is important for features like colored output or interactive prompts.
Returns:
- A boolean value indicating whether the current output is a TTY or Cygwin terminal.
func IsUnderHomebrew ¶
IsUnderHomebrew checks if a given binary path is managed under the Homebrew path.
This function is useful to verify if a binary is installed via Homebrew by comparing its location to the Homebrew binary directory.
Parameters:
- path: The path of the binary to check.
Returns:
- A boolean value indicating whether the binary is located under the Homebrew path.
func OpenBrowser ¶
OpenBrowser opens the default web browser at the specified URL.
Parameters:
- goos: The operating system name (e.g., "darwin", "windows", or "linux").
- url: The URL to open in the web browser.
Returns:
- An *exec.Cmd configured to open the URL. Note that you must call `cmd.Run()` or `cmd.Start()` on the returned command to execute it.
Panics:
- This function will panic if called without a TTY (e.g., not running in a terminal).
Types ¶
type ErrClosedPagerPipe ¶
type ErrClosedPagerPipe struct {
// contains filtered or unexported fields
}
ErrClosedPagerPipe is an error type returned when writing to a closed pager pipe.
type Pager ¶
type Pager struct {
Out io.Writer // The writer to send output to the pager.
ErrOut io.Writer // The writer to send error output to.
// contains filtered or unexported fields
}
Pager manages a pager process for displaying output in a paginated format.
It supports configuring the pager command, starting the pager process, and ensuring proper cleanup when the pager is no longer needed.
func NewPager ¶
func NewPager() *Pager
NewPager creates a new Pager instance with default settings.
If the "PAGER" environment variable is not set, the default command is "more".
func (*Pager) Set ¶
Set updates the pager command used to display output.
Parameters:
- cmd: The pager command (e.g., "less", "more").
func (*Pager) Start ¶
Start begins the pager process to display output.
If the pager command is "cat" or empty, it does nothing. The function also sets environment variables to optimize the behavior of certain pagers, like "less" and "lv".
Returns:
- An error if the pager command fails to start or if arguments cannot be parsed.