commands

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2022 License: GPL-3.0 Imports: 16 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
	}
)
View Source
var (
	Generators = func() []Command {
		var commands []Command

		commands = append(commands, hashGenerator{
			base:   NewBase("MD5 Hash Generator", ""),
			hasher: md5.New(),
		})

		commands = append(commands, hashGenerator{
			base:   NewBase("SHA1 Hash Generator", ""),
			hasher: sha1.New(),
		})

		commands = append(commands, hashGenerator{
			base:   NewBase("SHA256 Hash Generator", ""),
			hasher: sha256.New(),
		})

		commands = append(commands, hashGenerator{
			base:   NewBase("SHA512 Hash Generator", ""),
			hasher: sha512.New(),
		})

		commands = append(commands, secretGenerator{
			base:   NewBase("16 Character Secret", "").withoutInputDisplay(),
			length: 16,
		})

		commands = append(commands, secretGenerator{
			base:   NewBase("32 Character Secret", "").withoutInputDisplay(),
			length: 32,
		})

		commands = append(commands, secretGenerator{
			base:   NewBase("64 Character Secret", "").withoutInputDisplay(),
			length: 64,
		})

		commands = append(commands, uuidGenerator{
			base:   NewBase("UUID v1", "date-time and mac address").withoutInputDisplay(),
			random: false,
		})

		commands = append(commands, uuidGenerator{
			base:   NewBase("UUID v4", "randoms").withoutInputDisplay(),
			random: false,
		})

		commands = append(commands, uuidGenerator{
			base: NewBase("Nil UUID", "zero").withoutInputDisplay(),
			zero: true,
		})

		commands = append(commands, lipsumGenerator{
			base:       NewBase("Lipsum - 1 Paragraph", "").withoutInputDisplay(),
			paragraphs: 1,
		})
		commands = append(commands, lipsumGenerator{
			base:       NewBase("Lipsum - 2 Paragraphs", "").withoutInputDisplay(),
			paragraphs: 2,
		})
		commands = append(commands, lipsumGenerator{
			base:       NewBase("Lipsum - 3 Paragraphs", "").withoutInputDisplay(),
			paragraphs: 3,
		})

		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
	ShouldDisplayInput() bool
}

type Result added in v0.4.0

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

func NewResult added in v0.4.0

func NewResult(result string, commandName string) Result

func (Result) Command added in v0.4.0

func (r Result) Command() string

func (Result) IsFromCommand added in v0.4.0

func (r Result) IsFromCommand(cmd Command) bool

func (Result) Out added in v0.4.0

func (r Result) Out() string

Jump to

Keyboard shortcuts

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