Documentation
¶
Index ¶
Constants ¶
const ConfigName = ".tp.toml"
const TpDir = "gh-tp"
Variables ¶
var ErrInterrupted = errors.New("operation interrupted by user")
ErrInterrupted indicates that the operation was cancelled by the user (e.g., Ctrl+C).
var (
Verbose bool
)
Functions ¶
func BackupFile ¶ added in v0.4.0
BackupFile copies a file from source to destination. It relies on os package functions for path handling and permissions.
Parameters:
- source: Path to the source file.
- dest: Path to the destination file.
Returns:
- error: nil on success, or an error describing what went wrong (file ops).
Types ¶
type ConfigFile ¶ added in v0.3.0
type ConfigFile struct {
Name string // Name of the configuration file
Path string // Full path to the configuration file
Params ConfigParams // Configuration parameters stored in the file
}
ConfigFile represents the configuration file structure with its location and parameters
type ConfigParams ¶ added in v0.3.0
type ConfigParams struct {
Binary string `` /* 167-byte string literal not displayed */
PlanFile string `` /* 155-byte string literal not displayed */
MdFile string `` /* 172-byte string literal not displayed */
Verbose bool `` /* 154-byte string literal not displayed */
}
ConfigParams contains all configurable parameters for the application with validation rules and comments for documentation
type FileChecker ¶ added in v0.4.0
FileChecker is an interface for checking file existence This allows for dependency injection and easier testing
type FormRunner ¶ added in v0.4.0
type FormRunner interface {
Run() error
}
FormRunner is an interface for running UI forms This allows for dependency injection and easier testing of UI components
type HuhFormRunner ¶ added in v0.4.0
type HuhFormRunner struct {
// contains filtered or unexported fields
}
HuhFormRunner implements the FormRunner interface using the huh library
func (*HuhFormRunner) Run ¶ added in v0.4.0
func (h *HuhFormRunner) Run() error
Run displays a confirmation form to the user and captures their response
This method creates and runs a huh form with a confirmation prompt that allows the user to choose yes/no.
Returns:
error - Any error encountered while running the form
type RealFileChecker ¶ added in v0.4.0
type RealFileChecker struct{}
RealFileChecker implements the FileChecker interface for production use
func (*RealFileChecker) DoesExist ¶ added in v0.4.0
func (r *RealFileChecker) DoesExist(cfgFile string) bool
DoesExist checks if a file or directory exists at the specified path
This method uses the DoesExist function to determine if a path exists in the filesystem.
Parameters:
cfgFile - The file path to check for existence
Returns:
bool - true if the path exists, false otherwise
type RealUserPrompt ¶ added in v0.4.0
type RealUserPrompt struct{}
RealUserPrompt implements the UserPrompt interface for production use
func (*RealUserPrompt) AskOverwrite ¶ added in v0.4.0
func (r *RealUserPrompt) AskOverwrite(configExists bool) (bool, error)
AskOverwrite prompts the user about creating or overwriting a configuration file
This method uses the query function to ask the user whether to create a new configuration file or overwrite an existing one.
Parameters:
configExists - Whether the configuration file already exists
Returns:
bool - User's decision (true to create/overwrite, false otherwise) error - Any error encountered during user interaction
type SyntaxHighlight ¶
type SyntaxHighlight string
SyntaxHighlight represents the language identifier used for syntax highlighting in markdown.
const ( // SyntaxHighlightTerraform is the syntax highlighting identifier for // Terraform/OpenTofu code. SyntaxHighlightTerraform SyntaxHighlight = "terraform" )
type UserPrompt ¶ added in v0.4.0
UserPrompt is an interface for handling user interactions This allows for dependency injection and easier testing