Documentation
¶
Overview ¶
file: internal/cli/prompt.go
file: internal/cli/renderer.go
file: internal/cli/validator.go
Index ¶
- Constants
- func IsValidOperator(op string) bool
- type Prompter
- type Renderer
- func (r *Renderer) GetTemplateContent(templateName string) (string, error)
- func (r *Renderer) ListTemplates() ([]string, error)
- func (r *Renderer) RenderTemplate(templateName, outputPath string) error
- func (r *Renderer) RenderTemplateWithData(templateName string, data map[string]string) (string, error)
- type RuleBuilder
- type StdinPrompter
Constants ¶
const ( ColorGreen = "\033[32m" ColorYellow = "\033[33m" ColorBlue = "\033[34m" ColorReset = "\033[0m" )
ANSI Color Codes for better output
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 ¶
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 (*Renderer) GetTemplateContent ¶
GetTemplateContent returns the raw content of a specific template.
func (*Renderer) ListTemplates ¶
ListTemplates returns a list of available template names.
func (*Renderer) RenderTemplate ¶
RenderTemplate generates a rule file from a template.
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.