config

package
v2.2.2 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2025 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package config is responsible for setting the program config from command-line arguments

Index

Constants

View Source
const (
	EnvNoColor   = "NO_COLOR"
	EnvF2NoColor = "F2_NO_COLOR"
	EnvDebug     = "F2_DEBUG"
)
View Source
const (
	DefaultFixConflictsPattern = "(%d)"
	DefaultWorkingDir          = "."
)

Variables

View Source
var (
	Stdin  io.Reader = os.Stdin
	Stdout io.Writer = os.Stdout
	Stderr io.Writer = os.Stderr
)

Functions

func IsATTY

func IsATTY(fd uintptr) bool

IsATTY checks if the given file descriptor is associated with a terminal.

Types

type Config

type Config struct {
	Date                     time.Time      `json:"date"`
	BackupLocation           io.Writer      `json:"-"`
	Location                 *time.Location `json:"location"`
	ExcludeDirRegex          *regexp.Regexp `json:"exclude_dir_regex"`
	ExcludeRegex             *regexp.Regexp `json:"exclude_regex"`
	IncludeRegex             *regexp.Regexp `json:"include_regex"`
	Search                   *Search        `json:"search_regex"`
	FixConflictsPatternRegex *regexp.Regexp `json:"fix_conflicts_pattern_regex"`
	TargetDir                string         `json:"target_dir"`
	FixConflictsPattern      string         `json:"fix_conflicts_pattern"`
	CSVFilename              string         `json:"csv_filename"`
	BackupFilename           string         `json:"backup_filename"`
	WorkingDir               string         `json:"working_dir"`
	SortVariable             string         `json:"sort_variable"`
	Replacement              string         `json:"replacement"`
	DateTimeVariable         string         `json:"dt"`
	ExiftoolOpts             ExiftoolOpts   `json:"exiftool_opts"`
	FilesAndDirPaths         []string       `json:"files_and_dir_paths"`
	FindSlice                []string       `json:"find_slice"`
	ReplacementSlice         []string       `json:"replacement_slice"`
	ReplaceRange             []int          `json:"replace_range"`
	PairOrder                []string       `json:"pair_order"`
	ReplaceLimit             int            `json:"replace_limit"`
	StartNumber              int            `json:"start_number"`
	MaxDepth                 int            `json:"max_depth"`
	Sort                     Sort           `json:"sort"`
	Revert                   bool           `json:"revert"`
	IgnoreExt                bool           `json:"ignore_ext"`
	IgnoreCase               bool           `json:"ignore_case"`
	Verbose                  bool           `json:"verbose"`
	IncludeHidden            bool           `json:"include_hidden"`
	Quiet                    bool           `json:"quiet"`
	NoColor                  bool           `json:"no_color"`
	AutoFixConflicts         bool           `json:"auto_fix_conflicts"`
	Exec                     bool           `json:"exec"`
	StringLiteralMode        bool           `json:"string_literal_mode"`
	JSON                     bool           `json:"json"`
	Debug                    bool           `json:"debug"`
	Recursive                bool           `json:"recursive"`
	ResetIndexPerDir         bool           `json:"reset_index_per_dir"`
	OnlyDir                  bool           `json:"only_dir"`
	PipeOutput               bool           `json:"is_output_to_pipe"`
	ReverseSort              bool           `json:"reverse_sort"`
	AllowOverwrites          bool           `json:"allow_overwrites"`
	Pair                     bool           `json:"pair"`
	SortPerDir               bool           `json:"sort_per_dir"`
	Clean                    bool           `json:"clean"`
	ExifToolVarPresent       bool           `json:"-"`
	IndexPresent             bool           `json:"-"`
	IncludeDir               bool           `json:"include_dir"`
}

Config represents the program configuration.

func Get

func Get() *Config

Get retrives an already set config or panics if the configuration has not yet been initialized.

func Init

func Init(cmd *cli.Command, pipeOutput bool) (*Config, error)

Init initializes renaming configuration from command-line arguments and environmental variables.

func (*Config) SetFind added in v2.2.0

func (c *Config) SetFind(replacementIndex int) error

type ExiftoolOpts

type ExiftoolOpts struct {
	API             string `long:"api"             json:"api"`              // corresponds to the `-api` flag
	Charset         string `long:"charset"         json:"charset"`          // corresponds to the `-charset` flag
	CoordFormat     string `long:"coordFormat"     json:"coord_format"`     // corresponds to the `-coordFormat` flag
	DateFormat      string `long:"dateFormat"      json:"date_format"`      // corresponds to the `-dateFormat` flag
	ExtractEmbedded bool   `long:"extractEmbedded" json:"extract_embedded"` // corresponds to the `-extractEmbedded` flag
}

ExiftoolOpts defines supported options for customizing Exitool's output.

type Search struct {
	Regex    *regexp.Regexp `json:"regex"`
	FindCond *regexp.Regexp
	Index    int `json:"index"`
}

type Sort

type Sort int
const (
	SortDefault Sort = iota
	SortSize
	SortNatural
	SortMtime
	SortBtime
	SortAtime
	SortCtime
	SortTimeVar
	SortIntVar
	SortStringVar
)

func (Sort) String

func (s Sort) String() string

Jump to

Keyboard shortcuts

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