option

package
v0.0.0-...-2781e78 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package option provides utilities of option handling

Index

Constants

This section is empty.

Variables

View Source
var DefaultStringValue = "__DEFAULT_STRING_VALUE__"

Functions

func RegisterBoolFlag

func RegisterBoolFlag(cmd *cobra.Command, flagConfig *BoolFlag) error

RegisterBoolFlag register bool flag to provided cmd and viper

func RegisterInt64Flag

func RegisterInt64Flag(cmd *cobra.Command, flagConfig *Int64Flag) error

RegisterInt64Flag register int64 flag to provided cmd and viper

func RegisterStringFlag

func RegisterStringFlag(cmd *cobra.Command, flagConfig *StringFlag) error

RegisterStringFlag register string flag to provided cmd and viper

Types

type BoolFlag

type BoolFlag struct {
	*Flag
	Value bool
}

BoolFlag represents flag which can be specified as bool

type CmdConfig

type CmdConfig struct {
	Toggle bool
}

func NewRootCmdConfigFromViper

func NewRootCmdConfigFromViper() (*CmdConfig, error)

type CmdRawConfig

type CmdRawConfig struct {
	StartCmdConfig `mapstructure:",squash"`
	Toggle         bool
}

type Flag

type Flag struct {
	IsPersistent bool
	IsRequired   bool
	Shorthand    string
	Name         string
	Usage        string
	ViperName    string
}

Flag represents flag which can be specified

type Int64Flag

type Int64Flag struct {
	*Flag
	Value      int64
	IsDirName  bool
	IsFileName bool
}

Int64Flag represents flag which can be specified as string

type StartCmdConfig

type StartCmdConfig struct {
	TwitterConsumerKey          string `mapstructure:"TWITTER_CONSUMER_KEY"`
	TwitterConsumerSecret       string `mapstructure:"TWITTER_CONSUMER_SECRET"`
	BotTwitterAccessToken       string `mapstructure:"BOT_TWITTER_ACCESS_TOKEN"`
	BotTwitterAccessTokenSecret string `mapstructure:"BOT_TWITTER_ACCESS_TOKEN_SECRET"`
	ErrorTweetMessage           string `mapstructure:"ERROR_TWEET_MESSAGE"`
	SorryTweetMessage           string `mapstructure:"SORRY_TWEET_MESSAGE"`
	TweetKeyword                string `mapstructure:"TWEET_KEYWORD"`
	BotTwitterUserID            int64  `mapstructure:"BOT_TWITTER_USER_ID"`
	BotTwitterUserScreenName    string `mapstructure:"BOT_TWITTER_USER_SCREEN_NAME"`
	ClassifierServerHost        string `mapstructure:"CLASSIFIER_SERVER_HOST"`
	Port                        string `mapstructure:"PORT"`
}

StartCmdConfig is config for start command

func NewStartCmdConfigFromViper

func NewStartCmdConfigFromViper() (*StartCmdConfig, error)

NewStartCmdConfigFromViper generate config for start command from viper

type StringFlag

type StringFlag struct {
	*Flag
	Value      string
	IsDirName  bool
	IsFileName bool
}

StringFlag represents flag which can be specified as string

Jump to

Keyboard shortcuts

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