Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Debug bool
var DryRun bool
var Exists bool
var UserCommand string
Functions ¶
func ApplyTransform ¶ added in v0.5.0
ApplyTransform applies the transform template using extracted named groups If transform is empty, returns the original value unchanged
func Debugln ¶
func Debugln(format string, args ...interface{})
Debugln prints debug messages to stderr if Debug mode is enabled
func ParseParams ¶
func ParseParams()
ParseParams initializes the command-line flags and sets the global variables
Types ¶
type RepverCommand ¶
type RepverCommand struct {
// Name of the command
Name string `yaml:"name"`
// Params defines optional validation patterns for command-line parameters
Params []RepverParam `yaml:"params"`
// Targets is a list of files and patterns to modify
Targets []RepverTarget `yaml:"targets"`
// GitOptions configures Git operations to perform
GitOptions RepverGit `yaml:"git"`
}
func (*RepverCommand) GetParam ¶ added in v0.5.0
func (c *RepverCommand) GetParam(name string) *RepverParam
GetParam returns a param definition by name; if not found, it returns nil
func (*RepverCommand) GetParameterNames ¶
func (c *RepverCommand) GetParameterNames() ([]string, error)
GetParameterNames returns a list of all unique parameter names
func (*RepverCommand) Validate ¶
func (c *RepverCommand) Validate() error
Validate validates the RepverCommand structure
type RepverConfig ¶
type RepverConfig struct {
// Commands is an array of version modification commands
Commands []RepverCommand `yaml:"commands"`
}
func Load ¶
func Load(filePath string) (*RepverConfig, error)
Load reads a YAML file from the specified path and parses it into a RepverConfig structure
func Parse ¶
func Parse(yamlContent string) (*RepverConfig, error)
Parse takes a YAML string and parses it into a RepverConfig structure
func (*RepverConfig) GetCommand ¶
func (c *RepverConfig) GetCommand(name string) (*RepverCommand, error)
GetCommand returns a command by name; if not found, it returns an error
func (*RepverConfig) GetParameterNames ¶
func (c *RepverConfig) GetParameterNames() ([]string, error)
GetParameterNames returns a list of all unique parameter names
func (*RepverConfig) Validate ¶
func (c *RepverConfig) Validate() error
Validate validates the RepverConfig structure
type RepverGit ¶
type RepverGit struct {
// CreateBranch indicates whether to create a new branch
CreateBranch bool `yaml:"create_branch"`
// DeleteBranch indicates whether to delete the branch after execution
// Only used when ReturnToOriginalBranch is true
DeleteBranch bool `yaml:"delete_branch"`
// BranchName is the name for the new branch
BranchName string `yaml:"branch_name"`
// Commit indicates whether to commit changes
Commit bool `yaml:"commit"`
// CommitMessage is the message to use for the commit
CommitMessage string `yaml:"commit_message"`
// Push indicates whether to push changes
Push bool `yaml:"push"`
// Remote is the Git remote to push to
Remote string `yaml:"remote"`
// PullRequest specifies whether to open a PR (values: NO, GITHUB_CLI)
PullRequest string `yaml:"pull_request"`
// ReturnToOriginalBranch indicates whether to switch back to the original branch
ReturnToOriginalBranch bool `yaml:"return_to_original_branch"`
}
func (*RepverGit) BuildBranchName ¶
BuildBranchName builds the branch name by replacing placeholders with values
func (*RepverGit) BuildCommitMessage ¶
BuildCommitMessage builds the commit message by replacing placeholders with values
func (*RepverGit) GitOptionsSpecified ¶
GitOptionsSpecified checks if any Git options are specified
type RepverParam ¶ added in v0.5.0
type RepverParam struct {
// Name is the name of the parameter (must match command-line --param-<name>)
Name string `yaml:"name"`
// Pattern is the regex pattern to validate and extract values from the parameter
// It can contain named capture groups (e.g., (?P<major>\d+)) for use in transforms
Pattern string `yaml:"pattern"`
}
RepverParam defines a parameter validation configuration
func (*RepverParam) ExtractNamedGroups ¶ added in v0.5.0
func (p *RepverParam) ExtractNamedGroups(value string) (map[string]string, error)
ExtractNamedGroups extracts named groups from a value using the param's pattern Returns a map of group names to their captured values
func (*RepverParam) Validate ¶ added in v0.5.0
func (p *RepverParam) Validate() error
Validate validates the RepverParam structure
func (*RepverParam) ValidateValue ¶ added in v0.5.0
func (p *RepverParam) ValidateValue(value string) error
ValidateValue validates that a value matches the param's pattern
type RepverTarget ¶
type RepverTarget struct {
// Path to the target file
Path string `yaml:"path"`
// Pattern is the regex pattern to match content in the target file
Pattern string `yaml:"pattern"`
// Transform specifies how to transform parameter values using named groups from params
// Uses {{name}} syntax to reference named groups from the params pattern
// If not specified, the raw parameter value is used
Transform string `yaml:"transform"`
}
func (*RepverTarget) Execute ¶
func (t *RepverTarget) Execute(values map[string]string, extractedGroups map[string]string) (bool, error)
Execute performs the regex replacement on the file specified by Path. It reads the file, applies the regex pattern, and writes back the modified content. The values map contains the replacement values for named capture groups in the regex pattern. The extractedGroups map contains named groups extracted from param patterns for use in transforms. It returns true if the content was modified, false otherwise. In dry run mode, it outputs the changes that would be made without modifying the file. It returns an error if any issues occur during file reading, regex compilation, or writing.
func (*RepverTarget) GetParameterNames ¶
func (t *RepverTarget) GetParameterNames() ([]string, error)
GetParameterNames returns a list of all unique parameter names
func (*RepverTarget) GetTransformParamNames ¶ added in v0.5.0
func (t *RepverTarget) GetTransformParamNames() []string
GetTransformParamName extracts the param name that is referenced in a transform template Returns the first param name found in the transform, or empty string if none found
func (*RepverTarget) Validate ¶
func (t *RepverTarget) Validate() error
Validate validates the RepverTarget structure