cli

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: May 7, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

file: internal/cli/prompt.go

file: internal/cli/renderer.go

file: internal/cli/validator.go

Index

Constants

View Source
const (
	ColorGreen  = "\033[32m"
	ColorYellow = "\033[33m"
	ColorBlue   = "\033[34m"
	ColorReset  = "\033[0m"
)

ANSI Color Codes for better output

View Source
const ContextHelp = `` /* 929-byte string literal not displayed */

ContextHelp provides a formatted string with help about available variables and operators.

Variables

This section is empty.

Functions

func IsValidOperator

func IsValidOperator(op string) bool

IsValidOperator checks if a string is a valid rule condition operator.

Types

type Prompter

type Prompter interface {
	Ask(question string) (string, error)
	AskWithDefault(question, defaultVal string) (string, error)
	Confirm(question string) (bool, error)
	Select(question string, options []string) (int, error)
}

Prompter defines the interface for user interaction, allowing for mock implementations in tests.

type Renderer

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

Renderer handles the logic for listing, showing, and rendering rule templates.

func NewRenderer

func NewRenderer() *Renderer

NewRenderer creates a new template renderer.

func (*Renderer) GetTemplateContent

func (r *Renderer) GetTemplateContent(templateName string) (string, error)

GetTemplateContent returns the raw content of a specific template.

func (*Renderer) ListTemplates

func (r *Renderer) ListTemplates() ([]string, error)

ListTemplates returns a list of available template names.

func (*Renderer) RenderTemplate

func (r *Renderer) RenderTemplate(templateName, outputPath string) error

RenderTemplate generates a rule file from a template.

func (*Renderer) RenderTemplateWithData

func (r *Renderer) RenderTemplateWithData(templateName string, data map[string]string) (string, error)

RenderTemplateWithData renders a template with provided data.

type RuleBuilder

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

RuleBuilder interactively constructs a rule.Rule object.

func NewRuleBuilder

func NewRuleBuilder(p Prompter) *RuleBuilder

NewRuleBuilder creates a new interactive rule builder.

func (*RuleBuilder) BuildRule

func (rb *RuleBuilder) BuildRule() ([]byte, error)

BuildRule starts the interactive process to build a complete rule.

type StdinPrompter

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

StdinPrompter is the standard implementation of Prompter that reads from os.Stdin.

func NewPrompter

func NewPrompter() *StdinPrompter

NewPrompter creates a new prompter that reads from standard input.

func (*StdinPrompter) Ask

func (p *StdinPrompter) Ask(question string) (string, error)

Ask poses a question to the user and returns their input.

func (*StdinPrompter) AskWithDefault

func (p *StdinPrompter) AskWithDefault(question, defaultVal string) (string, error)

AskWithDefault poses a question with a default value.

func (*StdinPrompter) Confirm

func (p *StdinPrompter) Confirm(question string) (bool, error)

Confirm asks a yes/no question.

func (*StdinPrompter) Select

func (p *StdinPrompter) Select(question string, options []string) (int, error)

Select presents a list of options and asks the user to choose one.

Jump to

Keyboard shortcuts

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