config

package
v0.1.2-0...-99e1973 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2020 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PostFontNormal postFont = "norm"
	PostFontSans            = "sans"
	PostFontMono            = "mono"
	PostFontWrap            = "wrap"
	PostFontCode            = "code"
)

Valid appearance types for posts.

View Source
const (

	// Defaults for posts on Write.as.
	DefaultFont    = PostFontMono
	WriteasBaseURL = "https://write.as"
	DevBaseURL     = "https://development.write.as"
	TorBaseURL     = "http://writeas7pm7rcdqg.onion"
)

Application constants.

View Source
const (
	// ConfigFile is the full filename for application configuration files
	ConfigFile = "config.ini"
)
View Source
const (
	NoEditorErr = "Couldn't find default editor. Try setting $EDITOR environment variable in ~/.profile"
)

Variables

View Source
var PostFlags = []cli.Flag{
	cli.StringFlag{
		Name:  "c, b",
		Usage: "Optional blog to post to",
		Value: "",
	},
	cli.BoolFlag{
		Name:  "insecure",
		Usage: "Send request insecurely.",
	},
	cli.BoolFlag{
		Name:  "tor, t",
		Usage: "Perform action on Tor hidden service",
	},
	cli.IntFlag{
		Name:  "tor-port",
		Usage: "Use a different port to connect to Tor",
		Value: 9150,
	},
	cli.BoolFlag{
		Name:  "code",
		Usage: "Specifies this post is code",
	},
	cli.BoolFlag{
		Name:  "md",
		Usage: "Returns post URL with Markdown enabled",
	},
	cli.BoolFlag{
		Name:  "verbose, v",
		Usage: "Make the operation more talkative",
	},
	cli.StringFlag{
		Name:  "font",
		Usage: "Sets post font to given value",
		Value: DefaultFont,
	},
	cli.StringFlag{
		Name:  "lang",
		Usage: "Sets post language to given ISO 639-1 language code",
		Value: "",
	},
	cli.StringFlag{
		Name:  "user-agent",
		Usage: "Sets the User-Agent for API requests",
		Value: "",
	},
}

Available flags for creating posts

Functions

func Collection

func Collection(c *cli.Context) string

func CurrentUser

func CurrentUser(c *cli.Context) (string, error)

CurrentUser returns the username of the user taking action in the current cli.Context.

func Debug

func Debug() bool

func DeleteUser

func DeleteUser(c *cli.Context) error

func DirMustExist

func DirMustExist(dataDirName string)

DirMustExist checks for a directory, creates it if not found and either panics or logs and error depending on the status of Debug

func EditPostCmd

func EditPostCmd(fname string) *exec.Cmd

func GetConfiguredEditor

func GetConfiguredEditor() string

func GetFont

func GetFont(code bool, font string) string

func HostDirectory

func HostDirectory(c *cli.Context) (string, error)

HostDirectory returns the sub directory string for the host. Order of precedence is a host flag if any, then the configured default, if any

func IsDev

func IsDev() bool

func IsTor

func IsTor(c *cli.Context) bool

func Language

func Language(c *cli.Context, auto bool) string

func LoadUser

func LoadUser(c *cli.Context) (*writeas.AuthUser, error)

func MessageRetryCompose

func MessageRetryCompose(fname string) string

func SaveConfig

func SaveConfig(dataDir string, uc *Config) error

func SaveUser

func SaveUser(c *cli.Context, u *writeas.AuthUser) error

func TorPort

func TorPort(c *cli.Context) int

func TorURL

func TorURL(c *cli.Context) string

func UserAgent

func UserAgent(c *cli.Context) string

func UserDataDir

func UserDataDir(dataDirName string) string

UserDataDir returns a platform specific directory under the user's home directory

func UserHostDir

func UserHostDir(c *cli.Context) (string, error)

UserHostDir returns the path to the user data directory with the host based subpath if the host flag is set

Types

type APIConfig

type APIConfig struct {
}

APIConfig is not currently used

type Config

type Config struct {
	API     APIConfig     `ini:"api"`
	Default DefaultConfig `ini:"default"`
	Posts   PostsConfig   `ini:"posts"`
}

Config represents the entire base configuration

func LoadConfig

func LoadConfig(dataDir string) (*Config, error)

type DefaultConfig

type DefaultConfig struct {
	Host string `ini:"host"`
	User string `ini:"user"`
}

DefaultConfig stores the default host and user to authenticate with

type PostsConfig

type PostsConfig struct {
	Directory string `ini:"directory"`
}

PostsConfig stores the directory for the user post cache

Jump to

Keyboard shortcuts

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