Documentation
¶
Overview ¶
Package config manages configuration files for the twig tool.
Index ¶
- func ParseParams(args []string, kind string, opt OptionSetter) ([]string, error)
- func PrintJSON(v interface{}) error
- func ResolveID(ctx context.Context, cli *twitter.Client, specs []string) ([]string, error)
- func Save(cfg *Config, path string) error
- type Config
- type OptionSetter
- type ParsedArgs
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseParams ¶
func ParseParams(args []string, kind string, opt OptionSetter) ([]string, error)
ParseParams parses optional parameters by name into an options struct. Parameter names are prefixed with a colon, for example ":entities". It returns the unconsumed arguments or reports a descriptive error for an unknown parameter name.
func PrintJSON ¶
func PrintJSON(v interface{}) error
PrintJSON prints v as JSON to stdout. If v is a slice, the members of the slice are printed one by one; otherwise v is printed alone.
Types ¶
type Config ¶
type Config struct { // Required fields. See: https://developer.twitter.com/en/portal/dashboard APIKey string `yaml:"api_key"` APISecret string `yaml:"api_secret"` Token string `yaml:"access_token"` Secret string `yaml:"access_secret"` BearerToken string `yaml:"bearer_token,omitempty"` Users []*User `yaml:"users,omitempty"` AuthUser string `yaml:"-"` Log func(tag jape.LogTag, msg string) `yaml:"-"` LogMask jape.LogTag `yaml:"-"` // contains filtered or unexported fields }
Config represents the stored configuration data for the twig tools.
func (*Config) FindUsername ¶
FindUsername returns the access token for the given username, or nil.
func (*Config) NewBearerClient ¶
NewBearerClient returns a new Twitter client with a bearer token.
func (*Config) NewUserClient ¶
NewUserClient returns a new Twitter client with an access token for the specified username.
type OptionSetter ¶
OptionSetter represents the ability to set named optional Boolean options. This interface is satisfied by the option types from the twitter package.
type ParsedArgs ¶
type ParsedArgs struct { Keys []string // all arguments that are not field specs, in the order given Fields []types.Fields }
ParsedArgs is the result from a call to ParseArgs.
func ParseArgs ¶
func ParseArgs(args []string, dtype string) ParsedArgs
ParseArgs decodes an argument list consisting of IDs or names mixed with field specifiers and expansions. A field spec has the form "name:value", where name is the object type (for example "tweet", "user"), and value is an arbitrary string. An expansion has the form "+name".
If dtype != "", a spec of the form ":value" is treated as "dtype:value".