util

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package util provides helper functions for execution of commands and presenting their stderr and stdout in uniform way. Provides also a way to capture text generated by FlagSet as command line arguments' documentation (PrintDefaults)

Index

Constants

This section is empty.

Variables

View Source
var (
	Reset   = "\033[0m"
	Red     = "\033[31m"
	Green   = "\033[32m"
	Yellow  = "\033[33m"
	Blue    = "\033[34m"
	Magenta = "\033[35m"
	Cyan    = "\033[36m"
	Gray    = "\033[37m"
	White   = "\033[97m"
)

Functions

func CenterString

func CenterString(s string, w int) string

func FormatFlagUsage

func FormatFlagUsage(fs *flag.FlagSet) string

FormatFlagUsage returns a string containing the usage information for the given FlagSet.

func LogCommand

func LogCommand(c *exec.Cmd, p Printer) error

function LogCommand runs a command pretty-printing its stdout and stderr

func LogStartStop

func LogStartStop(msg string, command func(p Printer) error) error

LogStartStop is a helper function which executes a particular command with logging

func StripExtension

func StripExtension(p, expected string) (string, error)

Types

type Printer

type Printer func(a ...any)

Printer is a function printing its arguments

Jump to

Keyboard shortcuts

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