cmd

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2022 License: Apache-2.0 Imports: 68 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DocTypeMan      = "man"
	DocTypeMarkdown = "markdown"
	DocTypeReST     = "rest"
	DocTypeYaml     = "yaml"
)
View Source
const (
	FileTypeHTML     = "html"
	FileTypeJSON     = "json"
	FileTypeMarkdown = "markdown"
	FileTypePDF      = "pdf"
	FileTypeTOML     = "toml"
	FileTypeYAML     = "yaml"
)
View Source
const (
	ImTypeAudio = "audio"
	ImTypeFile  = "file"
	ImTypeID    = "id"
	ImTypePhoto = "photo"
	ImTypeText  = "text"
	ImTypeVideo = "video"
	ImTypeVoice = "voice"
)

Variables

View Source
var (
	ErrArgNotFound    = errors.New("argument not found")
	ErrConfNotFound   = errors.New("config not found")
	ErrEmptyResponse  = errors.New("response is empty")
	ErrFileNotFound   = errors.New("file not found")
	ErrFileType       = errors.New("file type not correct")
	ErrInitialFailed  = errors.New("initial failed")
	ErrInvalidIP      = errors.New("invalid IP")
	ErrInvalidLength  = errors.New("invalid length")
	ErrInvalidVar     = errors.New("invalid variable")
	ErrParseCert      = errors.New("can not correctly parse certificate")
	ErrResponseStatus = errors.New("response status code is not 200")
	ErrTokenNotFound  = errors.New("token not found")
)

Functions

func Config added in v0.0.12

func Config(subFn ConfigBlock) error

Get secret token from config.

func Examples added in v0.0.9

func Examples(s string) string

Print examples with color.

func Execute

func Execute()

func HTTPRequestContent added in v0.1.3

func HTTPRequestContent(url string, body io.Reader, methods ...string) ([]byte, error)

HttpRequestContent make a simple request to url, and return response body, default request method is get.

func OutputDefaultJSON added in v0.0.12

func OutputDefaultJSON(i any)

func OutputDefaultNone added in v0.1.0

func OutputDefaultNone(i any)

func OutputDefaultString added in v0.0.12

func OutputDefaultString(i any)

func OutputDefaultYAML added in v0.0.12

func OutputDefaultYAML(i any)

func OutputInterfaceString added in v0.1.3

func OutputInterfaceString(r rootOutput)

func PrintJSON added in v0.0.12

func PrintJSON(i any)

func PrintString added in v0.1.0

func PrintString(i any)

func PrintYAML added in v0.0.12

func PrintYAML(i any)

func ValidDomain added in v0.0.12

func ValidDomain(i any) bool

If i is a domain return true.

func ValidFile added in v0.0.12

func ValidFile(f string) bool

If f is a valid path return true.

func ValidIP added in v0.1.0

func ValidIP(i string) bool

If i is a ipv address return true.

func ValidIPv4 added in v0.1.0

func ValidIPv4(i string) bool

If i is a ipv4 address return true.

func ValidIPv6 added in v0.1.0

func ValidIPv6(i string) bool

If i is a ipv6 address return true.

func ValidURL added in v0.0.12

func ValidURL(u string) bool

If u is a valid url return true.

Types

type ByteSize added in v0.1.0

type ByteSize float64
const (
	KB ByteSize = 1 << (10 * iota)
	MB
	GB
	TB
	PB
	EB
	ZB
	YB
)

func (ByteSize) String added in v0.1.0

func (b ByteSize) String() string

type CertFlag added in v0.1.3

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

func (*CertFlag) Run added in v0.1.3

func (cf *CertFlag) Run(cmd *cobra.Command, args []string)

type ConfigBlock added in v0.1.0

type ConfigBlock string
const (
	ConfigBlockDiscord  ConfigBlock = "discord."
	ConfigBlockICP      ConfigBlock = "west."
	ConfigBlockLINE     ConfigBlock = "line."
	ConfigBlockSlack    ConfigBlock = "slack."
	ConfigBlockTelegram ConfigBlock = "telegram."
)

func (ConfigBlock) String added in v0.1.0

func (c ConfigBlock) String() string

type ConvertFlag added in v0.1.3

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

func (*ConvertFlag) Convert added in v0.1.3

func (c *ConvertFlag) Convert() error

func (*ConvertFlag) ConvertMarkdown2HTML added in v0.1.3

func (c *ConvertFlag) ConvertMarkdown2HTML() error

func (*ConvertFlag) ConvertMarkdown2PDF added in v0.1.3

func (c *ConvertFlag) ConvertMarkdown2PDF() error

func (*ConvertFlag) Load added in v0.1.3

func (c *ConvertFlag) Load() error

func (*ConvertFlag) Run added in v0.1.3

func (c *ConvertFlag) Run(cmd *cobra.Command, _ []string)

func (*ConvertFlag) WriteFile added in v0.1.3

func (c *ConvertFlag) WriteFile(content []byte) error

type DiscordFlag added in v0.1.3

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

func (*DiscordFlag) File added in v0.1.3

func (d *DiscordFlag) File() error

func (*DiscordFlag) Init added in v0.1.3

func (d *DiscordFlag) Init() error

func (*DiscordFlag) Run added in v0.1.3

func (d *DiscordFlag) Run(cmd *cobra.Command, args []string)

func (*DiscordFlag) Text added in v0.1.3

func (d *DiscordFlag) Text() error

func (*DiscordFlag) TextTTS added in v0.1.3

func (d *DiscordFlag) TextTTS() error

type DocFlag added in v0.1.3

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

func (*DocFlag) Run added in v0.1.3

func (d *DocFlag) Run(cmd *cobra.Command, _ []string)

type EncodeFlag added in v0.1.3

type EncodeFlag struct {
	// contains filtered or unexported fields
}
var Encoder EncodeFlag

func (*EncodeFlag) Base32HexDecode added in v0.1.3

func (e *EncodeFlag) Base32HexDecode(s string) ([]byte, error)

func (*EncodeFlag) Base32HexEncode added in v0.1.3

func (e *EncodeFlag) Base32HexEncode(i any) (string, error)

func (*EncodeFlag) Base32StdDecode added in v0.1.3

func (e *EncodeFlag) Base32StdDecode(s string) ([]byte, error)

func (*EncodeFlag) Base32StdEncode added in v0.1.3

func (e *EncodeFlag) Base32StdEncode(i any) (string, error)

func (*EncodeFlag) Base64StdDecode added in v0.1.3

func (e *EncodeFlag) Base64StdDecode(s string) ([]byte, error)

func (*EncodeFlag) Base64StdEncode added in v0.1.3

func (e *EncodeFlag) Base64StdEncode(i any) (string, error)

func (*EncodeFlag) Base64URLDecode added in v0.1.3

func (e *EncodeFlag) Base64URLDecode(s string) ([]byte, error)

func (*EncodeFlag) Base64URLEncode added in v0.1.3

func (e *EncodeFlag) Base64URLEncode(i any) (string, error)

func (*EncodeFlag) HexDecode added in v0.1.3

func (e *EncodeFlag) HexDecode(s string) ([]byte, error)

func (*EncodeFlag) HexEncode added in v0.1.3

func (e *EncodeFlag) HexEncode(i any) (string, error)

func (*EncodeFlag) JSONDecode added in v0.1.3

func (e *EncodeFlag) JSONDecode(r io.Reader, i any) (any, error)

func (*EncodeFlag) JSONEncode added in v0.1.3

func (e *EncodeFlag) JSONEncode(i any) (string, error)

func (*EncodeFlag) PemDecode added in v0.1.3

func (e *EncodeFlag) PemDecode(b []byte) (*pem.Block, error)

func (*EncodeFlag) PemEncode added in v0.1.3

func (e *EncodeFlag) PemEncode(b *pem.Block) (string, error)

func (*EncodeFlag) Run added in v0.1.3

func (e *EncodeFlag) Run(cmd *cobra.Command, args []string)

func (*EncodeFlag) RunDecode added in v0.1.3

func (e *EncodeFlag) RunDecode(cmd *cobra.Command, args []string)

func (*EncodeFlag) XMLDecode added in v0.1.3

func (e *EncodeFlag) XMLDecode(r io.Reader, i any) (any, error)

func (*EncodeFlag) XMLEncode added in v0.1.3

func (e *EncodeFlag) XMLEncode(i any) (string, error)

func (*EncodeFlag) YamlDecode added in v0.1.3

func (e *EncodeFlag) YamlDecode(r io.Reader, i any) (any, error)

func (*EncodeFlag) YamlEncode added in v0.1.3

func (e *EncodeFlag) YamlEncode(i any) (string, error)

type HashFlag added in v0.1.3

type HashFlag struct{}
var Hasher HashFlag

func (*HashFlag) Md5Hash added in v0.1.3

func (h *HashFlag) Md5Hash(i any) (string, error)

func (*HashFlag) Run added in v0.1.3

func (h *HashFlag) Run(cmd *cobra.Command, args []string)

func (*HashFlag) Sha1Hash added in v0.1.3

func (h *HashFlag) Sha1Hash(i any) (string, error)

func (*HashFlag) Sha256Hash added in v0.1.3

func (h *HashFlag) Sha256Hash(i any) (string, error)

func (*HashFlag) Sha512Hash added in v0.1.3

func (h *HashFlag) Sha512Hash(i any) (string, error)

func (*HashFlag) WriteFile added in v0.1.3

func (h *HashFlag) WriteFile(hasher hash.Hash, filename string) (string, error)

func (*HashFlag) WriteString added in v0.1.3

func (h *HashFlag) WriteString(hasher hash.Hash, i any) (string, error)

type IcpFlags added in v0.1.3

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

type LineFlag added in v0.1.3

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

func (*LineFlag) GetID added in v0.1.3

func (l *LineFlag) GetID()

func (*LineFlag) Init added in v0.1.3

func (l *LineFlag) Init() error

func (*LineFlag) Run added in v0.1.3

func (l *LineFlag) Run(cmd *cobra.Command, _ []string)

type OtpFlag added in v0.1.3

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

func (*OtpFlag) GenSecret added in v0.1.3

func (o *OtpFlag) GenSecret() (string, error)

func (*OtpFlag) HOTP added in v0.1.3

func (o *OtpFlag) HOTP(secret string, timeInterval int64) (string, error)

func (OtpFlag) RemoveSpaces added in v0.1.3

func (o OtpFlag) RemoveSpaces(s string) string

func (*OtpFlag) Run added in v0.1.3

func (o *OtpFlag) Run(cmd *cobra.Command, args []string)

func (*OtpFlag) SetAlgorithm added in v0.1.3

func (o *OtpFlag) SetAlgorithm() func() hash.Hash

func (*OtpFlag) SetDigits added in v0.1.3

func (o *OtpFlag) SetDigits() [2]int

func (*OtpFlag) SetTimeInterval added in v0.1.3

func (o *OtpFlag) SetTimeInterval() int64

func (*OtpFlag) TOTP added in v0.1.3

func (o *OtpFlag) TOTP(secret string) (string, error)

func (*OtpFlag) Verify added in v0.1.3

func (o *OtpFlag) Verify(secret string, input string) (bool, error)

type QrcodeFlag added in v0.1.3

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

func (*QrcodeFlag) Generate added in v0.1.3

func (q *QrcodeFlag) Generate() error

type RandomCharacter added in v0.1.2

type RandomCharacter string
const (
	LowercaseLetters RandomCharacter = "abcdefghijklmnopqrstuvwxyz"
	UppercaseLetters RandomCharacter = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
	Symbols          RandomCharacter = "~!@#$%^&*()_+`-={}|[]\\:\"<>?,./"
	Numbers          RandomCharacter = "0123456789"
	AllSet           RandomCharacter = LowercaseLetters + UppercaseLetters + Symbols + Numbers
)

type RandomFlag added in v0.1.3

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

func (*RandomFlag) Run added in v0.1.3

func (r *RandomFlag) Run(cmd *cobra.Command, _ []string)

type RandomString added in v0.1.3

type RandomString struct{}

func (RandomString) GenerateAll added in v0.1.3

func (r RandomString) GenerateAll(length, minLower, minUpper, minSymbol, minNumber int) (string, error)

type SlackFlag added in v0.1.3

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

func (*SlackFlag) Init added in v0.1.3

func (s *SlackFlag) Init() error

func (*SlackFlag) Photo added in v0.1.3

func (s *SlackFlag) Photo() error

func (*SlackFlag) Run added in v0.1.3

func (s *SlackFlag) Run(cmd *cobra.Command, _ []string)

func (*SlackFlag) Text added in v0.1.3

func (s *SlackFlag) Text() error

type SystemFlag added in v0.1.3

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

func (*SystemFlag) CPUInfo added in v0.1.3

func (s *SystemFlag) CPUInfo() error

func (*SystemFlag) DiskUsage added in v0.1.3

func (s *SystemFlag) DiskUsage() error

func (*SystemFlag) HostInfo added in v0.1.3

func (s *SystemFlag) HostInfo() error

func (*SystemFlag) LoadAvg added in v0.1.3

func (s *SystemFlag) LoadAvg() error

func (*SystemFlag) MemUsage added in v0.1.3

func (s *SystemFlag) MemUsage() error

func (*SystemFlag) NetInfo added in v0.1.3

func (s *SystemFlag) NetInfo() error

type TelegramFlag added in v0.1.3

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

func (TelegramFlag) Animation added in v0.1.3

func (t TelegramFlag) Animation() error

func (*TelegramFlag) Audio added in v0.1.3

func (t *TelegramFlag) Audio() error

func (TelegramFlag) ChatDescription added in v0.1.3

func (t TelegramFlag) ChatDescription() error

func (TelegramFlag) ChatPhoto added in v0.1.3

func (t TelegramFlag) ChatPhoto() error

func (TelegramFlag) ChatTitle added in v0.1.3

func (t TelegramFlag) ChatTitle() error

func (TelegramFlag) Dice added in v0.1.3

func (t TelegramFlag) Dice() error

func (*TelegramFlag) File added in v0.1.3

func (t *TelegramFlag) File() error

func (*TelegramFlag) GetUpdate added in v0.1.3

func (t *TelegramFlag) GetUpdate()

func (*TelegramFlag) Init added in v0.1.3

func (t *TelegramFlag) Init() error

func (*TelegramFlag) Photo added in v0.1.3

func (t *TelegramFlag) Photo() error

func (*TelegramFlag) Run added in v0.1.3

func (t *TelegramFlag) Run(cmd *cobra.Command, _ []string)

func (*TelegramFlag) Text added in v0.1.3

func (t *TelegramFlag) Text() error

func (*TelegramFlag) Video added in v0.1.3

func (t *TelegramFlag) Video() error

func (*TelegramFlag) Voice added in v0.1.3

func (t *TelegramFlag) Voice() error

type VersionOutput added in v0.1.3

type VersionOutput struct {
	Version string `json:"version,omitempty" yaml:"version,omitempty"`
	Commit  string `json:"commit,omitempty" yaml:"commit,omitempty"`
	Date    string `json:"date,omitempty" yaml:"date,omitempty"`
	Runtime string `json:"runtime,omitempty" yaml:"runtime,omitempty"`
}

func (VersionOutput) String added in v0.1.3

func (r VersionOutput) String()

type WhoisFlag added in v0.1.3

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

func (WhoisFlag) CalculateDays added in v0.1.3

func (w WhoisFlag) CalculateDays(t string) (int, error)

Convert time to days.

func (WhoisFlag) ParseTime added in v0.1.3

func (w WhoisFlag) ParseTime(t string) (string, error)

Convert time to RFC3339 format.

func (WhoisFlag) Request added in v0.1.3

func (w WhoisFlag) Request(domain string) (*WhoisResponse, error)

type WhoisResponse added in v0.1.3

type WhoisResponse struct {
	Registrar   string   `json:"registrar" yaml:"registrar"`
	CreatedDate string   `json:"createdDate" yaml:"createdDate"`
	ExpiresDate string   `json:"expiresDate" yaml:"expiresDate"`
	UpdatedDate string   `json:"updatedDate" yaml:"updatedDate"`
	RemainDays  int      `json:"remainDays" yaml:"remainDays"`
	NameServers []string `json:"nameServers" yaml:"nameServers"`
}

func (WhoisResponse) String added in v0.1.3

func (r WhoisResponse) String()

Jump to

Keyboard shortcuts

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