Unify

package module
v0.0.0-...-ff4a37b Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2022 License: GPL-2.0 Imports: 15 Imported by: 2

Documentation

Overview

Package Unify - This package contains common functionality that's used across multiple binaries. It's an easy way to include some important functionality into every binary. Currently, it provides: - Cron scheduler. - Daemonizing a process. - Logging. - Version control and self-update. - Cobra/Viper integration. - Interactive shell based on Cobra CLI commands.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CmdRoot

func CmdRoot(_ *cobra.Command, args []string) error

CmdRoot -

Types

type Commands

type Commands struct {
	CmdRoot    *cobra.Command
	CmdVersion *cmdVersion.Version
	CmdDaemon  *cmdDaemon.Daemon
	CmdCron    *cmdCron.Cron
	CmdConfig  *cmdConfig.Config
	// CmdSystray *cmdSystray.Config
	CmdHelp  *cmdHelp.Help
	CmdShell *cmdShell.Shell
}

func (*Commands) Execute

func (c *Commands) Execute() error

Execute -

type Flags

type Flags struct {
	ConfigFile string        `json:"config_file"`
	ConfigDir  string        `json:"config_dir"`
	CacheDir   string        `json:"cache_dir"`
	Quiet      bool          `json:"quiet"`
	Debug      bool          `json:"debug"`
	Timeout    time.Duration `json:"timeout"`
}

type Options

type Options struct {
	Description   string `json:"description"`
	BinaryName    string `json:"binary_name"`
	BinaryVersion string `json:"binary_version"`
	SourceRepo    string `json:"source_repo"`
	BinaryRepo    string `json:"binary_repo"`
	EnvPrefix     string `json:"env_prefix"`
	HelpSummary   string `json:"help_template"`
	ReadMe        string `json:"readme"`
	Examples      string `json:"examples"`
}

type Unify

type Unify struct {
	Options  Options  `json:"options"`
	Flags    Flags    `json:"flags"`
	Commands Commands `json:"commands"`

	Error error `json:"-"`
}

func New

func New(options Options, flags Flags) *Unify

New - Create new Unify instance.

func (*Unify) Execute

func (u *Unify) Execute() error

Execute -

func (*Unify) GetCacheDir

func (u *Unify) GetCacheDir() string

GetCacheDir -

func (*Unify) GetCmd

func (u *Unify) GetCmd() *cobra.Command

GetCmd -

func (*Unify) GetConfigDir

func (u *Unify) GetConfigDir() string

GetConfigDir -

func (*Unify) GetConfigFile

func (u *Unify) GetConfigFile() string

GetConfigFile -

func (*Unify) GetEnvPrefix

func (u *Unify) GetEnvPrefix() string

func (*Unify) GetViper

func (u *Unify) GetViper() *viper.Viper

GetViper -

func (*Unify) InitCmds

func (u *Unify) InitCmds() error

InitCmds -

func (*Unify) InitFlags

func (u *Unify) InitFlags() error

InitFlags -

func (*Unify) ReadConfig

func (u *Unify) ReadConfig() error

ReadConfig -

func (*Unify) WriteConfig

func (u *Unify) WriteConfig() error

WriteConfig -

Jump to

Keyboard shortcuts

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