config

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FlagConfig = "config"

	FlagCount    = "count"
	FlagWordlist = "wordlist"
	FlagTemplate = "template"
	FlagProfile  = "profile"
)

Variables

View Source
var ErrProfileNotFound = errors.New("profile not found")

Functions

func GetDir

func GetDir() (string, error)

func GetFile

func GetFile() (string, error)

func GetFilePretty

func GetFilePretty() (string, error)

func NewContext

func NewContext(ctx context.Context, conf *Config) context.Context

Types

type Config

type Config struct {
	File string `toml:"-"`

	Count    int           `toml:"count" comment:"Number of passphrases to generate."`
	Profile  ProfileRef    `toml:"profile" comment:"Default profile used to generate passphrases."`
	Param    any           `toml:"-"`
	Profiles ProfileMap    `toml:"profiles" comment:"Preconfigured profiles and default parameters."`
	Wordlist wordlist.Meta `toml:"wordlist" comment:"Wordlist to use. (one of: long, short1, short2)"`
	Template string        `toml:"template" comment:"Default template used to generate passphrases. If not empty, will override the default profile." `
}

func FromContext

func FromContext(ctx context.Context) (*Config, bool)

func Load

func Load(cmd *cobra.Command, save bool) (*Config, error)

func New added in v0.5.0

func New() *Config

func (*Config) RegisterFlags added in v0.5.0

func (c *Config) RegisterFlags(cmd *cobra.Command)

type NamedProfile added in v0.4.0

type NamedProfile struct {
	Name string
	Profile
}

type Profile added in v0.2.0

type Profile struct {
	Template string `toml:"template"`
	Param    int    `toml:"param,omitempty"`
}

type ProfileMap added in v0.4.0

type ProfileMap map[string]Profile

func (ProfileMap) Named added in v0.4.0

func (p ProfileMap) Named() []NamedProfile

type ProfileRef added in v0.2.0

type ProfileRef struct {
	Name  string
	Param int
}

func (*ProfileRef) MarshalText added in v0.2.0

func (p *ProfileRef) MarshalText() ([]byte, error)

func (*ProfileRef) UnmarshalText added in v0.2.0

func (p *ProfileRef) UnmarshalText(text []byte) error

type TOMLParser

type TOMLParser struct{}

func (TOMLParser) Marshal

func (p TOMLParser) Marshal(o map[string]interface{}) ([]byte, error)

func (TOMLParser) Unmarshal

func (p TOMLParser) Unmarshal(b []byte) (map[string]interface{}, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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