helpers

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package helpers provides CLI-specific helper functions for Tempo commands.

This package contains utilities that are specifically designed for CLI command implementations and should only be imported by packages in cmd/tempo/*.

Logger Helpers (logger.go)

Functions for managing logger state in CLI commands:

  • EnableLoggerIndentation - Enable indented output for nested logging
  • ResetLogger - Reset logger to default state after command completion
  • LogSuccessMessages - Log standardized success messages for entity creation

Error Builders (errors.go)

Functions for building user-friendly error messages:

  • BuildMissingFoldersError - Build error message for missing folder validation

Entity Helpers (entity.go)

Functions for handling entity existence checks in CLI commands:

  • CheckEntityForNew - Log warning/info when creating entities that exist
  • CheckEntityForDefine - Log warning/info when defining templates that exist

Usage

These helpers are designed to be used in CLI command implementations:

func runCommand(cmdCtx *app.AppContext) func(ctx context.Context, cmd *cli.Command) error {
    return func(ctx context.Context, cmd *cli.Command) error {
        helpers.EnableLoggerIndentation(cmdCtx.Logger)
        defer helpers.ResetLogger(cmdCtx.Logger)

        // Command implementation...

        return nil
    }
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildMissingFoldersError

func BuildMissingFoldersError(missingFolders map[string]string, contextMsg string, helpCommands []string) error

BuildMissingFoldersError constructs an error message for missing folders.

func CheckEntityForDefine added in v0.3.0

func CheckEntityForDefine(entityType, outputPath string, force bool, logr logger.Logger)

CheckEntityForDefine logs a warning or info message when defining templates that already exist.

func CheckEntityForNew added in v0.3.0

func CheckEntityForNew(entityType, entityName, outputPath string, force bool, logr logger.Logger)

CheckEntityForNew logs a warning or info message when creating a new entity that already exists. It handles both component and variant entity types with appropriate path formatting.

func EnableLoggerIndentation

func EnableLoggerIndentation(log logger.Logger)

EnableLoggerIndentation ensures consistent indentation.

func LogSuccessMessages

func LogSuccessMessages(entityType string, cfg *config.Config, logger logger.Logger)

LogSuccessMessages logs the success messages for generated template files and assets.

func ResetLogger

func ResetLogger(log logger.Logger)

Types

This section is empty.

Jump to

Keyboard shortcuts

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