commands

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2022 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Converters = func() []Command {
		var converters []Command

		converters = append(converters, yamlToJson{
			base: NewBase("YAML -> JSON", "Convert YAML to JSON"),
		})
		converters = append(converters, jsonToYaml{
			base: NewBase("JSON -> YAML", "Convert JSON to YAML"),
		})

		bases := []int{2, 8, 10, 16}
		for _, from := range bases {
			for _, to := range bases {
				if from != to {
					converters = append(converters, numberBaseConverter{
						base:     NewBase(fmt.Sprintf("%s -> %s", toPrettyBase(from), toPrettyBase(to)), ""),
						fromBase: from,
						toBase:   to,
					})
				}
			}
		}
		return converters
	}
)
View Source
var (
	Formatters = func() []Command {
		var commands []Command

		commands = append(commands, jsonPrettifier{
			base: NewBase("JSON Pretty Print", ""),
		})

		commands = append(commands, jsonMinifier{
			base: NewBase("JSON Minifier", ""),
		})

		return commands
	}
)

Functions

func NewBase

func NewBase(name, desc string) base

Types

type Category

type Category struct {
	Title       string
	Prompt      string
	Subcommands []Command
	Cursor      int
}

func NewCategory

func NewCategory(title, prompt string, subcommands ...Command) *Category

func (*Category) CursorDown

func (c *Category) CursorDown()

func (*Category) CursorUp

func (c *Category) CursorUp()

func (*Category) Selected

func (c *Category) Selected() Command

type Command

type Command interface {
	Name() string
	Exec(string) (string, error)
	DisplayInput(string) string
	DisplayOutput(string) string
}

Jump to

Keyboard shortcuts

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