cli

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package cli provides the command-line interface logic and orchestration for gitcommit.

Index

Constants

View Source
const (
	// ExitSuccess indicates successful execution.
	ExitSuccess = 0
	// ExitError indicates an error occurred.
	ExitError = 1
)
View Source
const (
	// RequiredArguments is the number of arguments required for normal operation.
	RequiredArguments = 2
)

Variables

This section is empty.

Functions

func FormatSuccessMessage

func FormatSuccessMessage(gitFormattedDate string) string

FormatSuccessMessage formats a success message with a checkmark.

func HelpText

func HelpText() string

HelpText returns the formatted help text for the gitcommit tool.

Types

type App

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

App represents the main application logic.

func NewApp

func NewApp(config *Config) *App

NewApp creates a new App instance.

func (*App) Run

func (a *App) Run() error

Run executes the main application logic.

type CommitRequest

type CommitRequest struct {
	// InputDate is the raw date string provided by the user.
	InputDate string

	// CommitMessage is the commit message text.
	CommitMessage string

	// ParsedDate is the parsed and validated date with timezone.
	ParsedDate time.Time

	// GitFormattedDate is the date formatted for Git environment variables.
	GitFormattedDate string
}

CommitRequest represents a user's request to create a commit with a specific date.

func NewCommitRequest

func NewCommitRequest(date, message string) *CommitRequest

NewCommitRequest creates a new CommitRequest from user input.

type Config

type Config struct {
	// Version is the semantic version of the tool.
	Version string

	// ShowHelp indicates whether the --help flag was provided.
	ShowHelp bool

	// ShowVersion indicates whether the --version flag was provided.
	ShowVersion bool

	// Args contains positional arguments after flag parsing.
	Args []string
}

Config holds the configuration for the CLI application.

func NewConfig

func NewConfig(version string) *Config

NewConfig creates a new Config with the specified version.

func (*Config) GetDate

func (c *Config) GetDate() string

GetDate returns the date argument.

func (*Config) GetMessage

func (c *Config) GetMessage() string

GetMessage returns the commit message argument.

func (*Config) Validate

func (c *Config) Validate() error

Validate checks if the configuration is valid for normal operation.

type ErrorType

type ErrorType int

ErrorType represents different categories of errors that can occur.

type UserError

type UserError struct {
	Type    string
	Message string
	Details string
	Hint    string
}

UserError represents an error with a user-friendly message.

func NewChronologyViolationError

func NewChronologyViolationError(providedDate, lastCommitDate string, equal bool) *UserError

NewChronologyViolationError creates an error when date is before last commit.

func NewGitCommandError

func NewGitCommandError(gitError string) *UserError

NewGitCommandError creates an error when a Git command fails.

func NewInvalidDateFormatError

func NewInvalidDateFormatError(provided string) *UserError

NewInvalidDateFormatError creates an error for invalid date format.

func NewInvalidDateValueError

func NewInvalidDateValueError(date string, reason string) *UserError

NewInvalidDateValueError creates an error for invalid calendar dates.

func NewMissingArgumentsError

func NewMissingArgumentsError(expected, received int) *UserError

NewMissingArgumentsError creates an error when arguments are missing.

func NewNoRepositoryError

func NewNoRepositoryError() *UserError

NewNoRepositoryError creates an error when not in a Git repository.

func (*UserError) Error

func (e *UserError) Error() string

Error implements the error interface.

Jump to

Keyboard shortcuts

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