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

config

package
v0.1.0-alpha.0 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package config defines the global configuration for git-iter-go. Settings are resolved in priority order: default < environment variable < CLI flag, using github.com/berquerant/structconfig.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseLogLevel

func ParseLogLevel(s string) (slog.Level, error)

ParseLogLevel converts a level string (e.g. "debug", "info", "warn", "error") to slog.Level. Defaults to slog.LevelInfo if empty.

func SetFlags

func SetFlags(fs *pflag.FlagSet) error

SetFlags registers all Config fields as flags on fs.

Types

type Config

type Config struct {
	// MaxProcs is the maximum number of parallel processes.
	MaxProcs int `name:"max-procs" default:"1" usage:"maximum number of parallel processes" short:"p"`
	// ReposRoot is the root directory scanned for git repositories when ListRepos is empty.
	ReposRoot string `name:"repos-root" default:"" usage:"root directory of local repositories" short:"r"`
	// ListRepos is an optional shell command whose stdout lists absolute repository paths.
	// When set, ReposRoot is ignored for discovery.
	ListRepos string `name:"list-repos" default:"" usage:"command to list absolute paths of repositories (one per line)"`
	// AbsPath controls whether grep/path-annotated output shows absolute paths (true) or paths
	// relative to ReposRoot (false).
	AbsPath bool `name:"abs-path" default:"false" usage:"show absolute paths in command output" short:"a"`
	// FailFast aborts execution immediately when an error occurs in any repository.
	FailFast bool `name:"fail-fast" default:"false" usage:"abort immediately when any repository command fails"`
	// LogLevel sets the logging level (debug, info, warn, error).
	LogLevel string `name:"log-level" default:"info" usage:"logging level (debug, info, warn, error)" short:"l"`
	// GitCommand is the path or name of the git binary.
	GitCommand string `name:"git-command" default:"git" usage:"path to git executable"`
	// Timeout is the maximum execution duration for each process.
	Timeout time.Duration `name:"timeout" default:"0s" usage:"timeout for each process execution (e.g. 5s, 1m)"`
	// MarkdownHeaderLevel is the heading level (1-6) for repository sections in markdown output.
	MarkdownHeaderLevel int `name:"markdown-header-level" default:"3" usage:"heading level for markdown sections (1-6)"`
	// Sort sorts repository paths in ascending order.
	Sort bool `name:"sort" default:"false" usage:"sort repository paths in ascending order"`
	// SortReverse sorts repository paths in descending order.
	SortReverse bool `name:"sort-reverse" default:"false" usage:"sort repository paths in descending order"`
	// Limit limits the number of processed repositories to the first n repos (after sorting if applicable).
	Limit int `name:"limit" default:"0" usage:"limit the number of processed repositories" short:"n"`
	// DirtyOnly filters repositories to only those with uncommitted changes, staged changes, or untracked files.
	DirtyOnly bool `name:"dirty-only" default:"false" usage:"only include dirty repositories" short:"d"`
	// CleanOnly filters repositories to only those without uncommitted changes or untracked files.
	CleanOnly bool `name:"clean-only" default:"false" usage:"only include clean repositories" short:"c"`
	// RemoteURL filters repositories to only those whose origin remote URL matches the specified regex pattern.
	RemoteURL string `name:"remote-url" default:"" usage:"filter repositories by origin remote URL regex pattern"`
}

Config holds all global settings for git-iter.

func Resolve

func Resolve(fs *pflag.FlagSet) (*Config, error)

Resolve builds a Config by merging: default < env < already-parsed flags. fs must already be parsed before calling Resolve.

func (*Config) GitCommandOrFallback

func (c *Config) GitCommandOrFallback() string

GitCommandOrFallback returns GitCommand if set, otherwise "git".

Jump to

Keyboard shortcuts

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