config

package
v0.0.0-...-f271d2a Latest Latest
Warning

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

Go to latest
Published: May 23, 2019 License: ISC Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	HomeDir     string `long:"appdata" description:"Path to application home directory"`
	Host        string `long:"host" description:"politeiawww host"`
	RawJSON     bool   `short:"j" long:"json" description:"Print raw JSON output"`
	ShowVersion bool   `short:"V" long:"version" description:"Display version information and exit"`
	SkipVerify  bool   `long:"skipverify" description:"Skip verifying the server's certifcate chain and host name"`
	Verbose     bool   `short:"v" long:"verbose" description:"Print verbose output"`
	Silent      bool   `long:"silent" description:"Suppress all output"`

	DataDir    string // Application data dir
	Version    string // CLI version
	WalletHost string // Wallet host
	WalletCert string // Wallet GRPC certificate
	FaucetHost string // Testnet faucet host
	CSRF       string // CSRF header token

	Identity *identity.FullIdentity // User identity
	Cookies  []*http.Cookie         // User cookies
}

Config represents the politeiawwwcli configuration settings.

func Load

func Load() (*Config, error)

Load initializes and parses the config using a config file and command line options.

The configuration proceeds as follows:

  1. Start with a default config with sane settings
  2. Pre-parse the command line to check for an alternative config file
  3. Load configuration file overwriting defaults with any specified options
  4. Parse CLI options and overwrite/add any specified options

The above results in politeiawwwcli functioning properly without any config settings while still allowing the user to override settings with config files and command line options. Command line options always take precedence.

func (*Config) SaveCSRF

func (cfg *Config) SaveCSRF(csrf string) error

SaveCSRF writes the passed in CSRF token to the host specific CSRF file.

func (*Config) SaveCookies

func (cfg *Config) SaveCookies(cookies []*http.Cookie) error

SaveCookies writes the passed in cookies to the host specific cookie file.

func (*Config) SaveIdentity

func (cfg *Config) SaveIdentity(user string, id *identity.FullIdentity) error

SaveIdentity writes the passed in user identity to disk so that it can be persisted between commands. The prepend the hostname and the username onto the idenity filename so that we can keep track of the identities for multiple users per host.

func (*Config) SaveLoggedInUsername

func (cfg *Config) SaveLoggedInUsername(username string) error

SaveLoggedInUsername saved the passed in username to the on-disk user file. We persist the logged in username between commands so that we know which identity to load.

Jump to

Keyboard shortcuts

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