Help us shape the future of Go! Take the 2026 Go Developer Survey

utils

package
v0.19.7 Latest Latest
Warning

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

Go to latest
Published: May 2, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsVerbose added in v0.14.3

func IsVerbose(cmd *cobra.Command) bool

IsVerbose checks if the "verbose" flag is set for the given Cobra command. It first checks if the verbose flag is explicitly set on the command. If not, it falls back to the config value using viper.

Parameters:

  • cmd: A pointer to a Cobra command from which the "verbose" flag is retrieved.

Returns:

  • bool: True if the "verbose" flag is set to true, otherwise false.

func StartChildProcess

func StartChildProcess(c *exec.Cmd) error

StartChildProcess starts a child process with the given exec.Cmd configuration. It sets up the standard input, output, and error streams to be the same as the parent process. Additionally, it captures interrupt signals (ctl + c) and forwards them to the child process.

Parameters:

  • c: A pointer to an exec.Cmd struct representing the command to be executed.

Returns:

  • error: An error if the command fails to start or exits with a non-zero status. Returns nil if the command completes successfully.

The function starts the command and waits for it to finish.

func SyncDirectory

func SyncDirectory(srcDir, destDir string, isVerbose bool) error

SyncDirectory synchronizes the contents of the source directory (srcDir) with the destination directory (destDir). It copies files and recursively syncs subdirectories. If isVerbose is true, it logs the files being copied.

Parameters:

  • srcDir: The source directory to sync from.
  • destDir: The destination directory to sync to.
  • isVerbose: A boolean flag to enable verbose logging.

Returns:

  • error: An error if any occurs during the synchronization process., otherwise nil.

Types

type Spinner added in v0.17.21

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

func NewProgressSpinner added in v0.17.22

func NewProgressSpinner(message string) *Spinner

NewProgressSpinner creates a new spinner styled as a progress bar. Use SetProgressBar() on the returned spinner to update its progress.

func NewSpinner added in v0.17.21

func NewSpinner(message string) *Spinner

NewSpinner creates a new standard spinner with the given message.

func (*Spinner) SetProgressBar added in v0.17.22

func (sp *Spinner) SetProgressBar(progress float64, msg ...string)

SetProgressBar updates the visual progress of the spinner. It assumes the spinner was created using NewProgressSpinner or configured with a character set suitable for displaying progress steps (like CharSets[36]). The progress value should be between 0.0 and 1.0. If msg is provided, it overrides the base message for this update. If msg is not provided, the stored base message is used.

func (*Spinner) Start added in v0.17.21

func (sp *Spinner) Start()

func (*Spinner) Stop added in v0.17.21

func (sp *Spinner) Stop()

func (*Spinner) UpdateMessage added in v0.17.21

func (sp *Spinner) UpdateMessage(msg string)

UpdateMessage updates the base message of the spinner. For non-progress spinners, it updates the suffix immediately. For progress spinners, the change will be reflected on the next SetProgressBar call if no specific message is provided to SetProgressBar.

Directories

Path Synopsis
Package config is a helper package to facilitate getting and setting config values using Viper.
Package config is a helper package to facilitate getting and setting config values using Viper.
Package log is a wrapper around colorizing the log output.
Package log is a wrapper around colorizing the log output.

Jump to

Keyboard shortcuts

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