utils

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: May 2, 2020 License: LGPL-3.0 Imports: 15 Imported by: 2

Documentation

Overview

Package utils contains internal helper functions for go-fractal commands.

Index

Constants

This section is empty.

Variables

View Source
var (
	CommandHelpTemplate = `` /* 471-byte string literal not displayed */

)

Functions

func Fatalf

func Fatalf(format string, args ...interface{})

Fatalf formats a message to standard error and exits the program. The message is also printed to standard output if standard error is redirected to a different file.

func GlobalBig

func GlobalBig(ctx *cli.Context, name string) *big.Int

GlobalBig returns the value of a BigFlag from the global flag set.

func NewApp

func NewApp(versionMeta, gitCommit, usage string) *cli.App

NewApp creates an app with sane defaults.

Types

type BigFlag

type BigFlag struct {
	Name  string
	Value *big.Int
	Usage string
}

BigFlag is a command line flag that accepts 256 bit big integers in decimal or hexadecimal syntax.

func (BigFlag) Apply

func (f BigFlag) Apply(set *flag.FlagSet)

func (BigFlag) GetName

func (f BigFlag) GetName() string

func (BigFlag) String

func (f BigFlag) String() string

type DirectoryFlag

type DirectoryFlag struct {
	Name  string
	Value DirectoryString
	Usage string
}

Custom cli.Flag type which expand the received string to an absolute path. e.g. ~/test -> /home/username/test

func (DirectoryFlag) Apply

func (self DirectoryFlag) Apply(set *flag.FlagSet)

called by cli library, grabs variable from environment (if in env) and adds variable to flag set for parsing.

func (DirectoryFlag) GetName

func (self DirectoryFlag) GetName() string

func (*DirectoryFlag) Set

func (self *DirectoryFlag) Set(value string)

func (DirectoryFlag) String

func (self DirectoryFlag) String() string

type DirectoryString

type DirectoryString struct {
	Value string
}

Custom type which is registered in the flags library which cli uses for argument parsing. This allows us to expand Value to an absolute path when the argument is parsed

func (*DirectoryString) Set

func (self *DirectoryString) Set(value string) error

func (*DirectoryString) String

func (self *DirectoryString) String() string

type TextMarshaler

type TextMarshaler interface {
	encoding.TextMarshaler
	encoding.TextUnmarshaler
}

func GlobalTextMarshaler

func GlobalTextMarshaler(ctx *cli.Context, name string) TextMarshaler

GlobalTextMarshaler returns the value of a TextMarshalerFlag from the global flag set.

type TextMarshalerFlag

type TextMarshalerFlag struct {
	Name  string
	Value TextMarshaler
	Usage string
}

TextMarshalerFlag wraps a TextMarshaler value.

func (TextMarshalerFlag) Apply

func (f TextMarshalerFlag) Apply(set *flag.FlagSet)

func (TextMarshalerFlag) GetName

func (f TextMarshalerFlag) GetName() string

func (TextMarshalerFlag) String

func (f TextMarshalerFlag) String() string

Jump to

Keyboard shortcuts

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