Documentation ¶
Index ¶
- Constants
- Variables
- func Collection(c *cli.Context) string
- func CurrentUser(c *cli.Context) (string, error)
- func Debug() bool
- func DeleteUser(c *cli.Context) error
- func DirMustExist(dataDirName string)
- func EditPostCmd(fname string) *exec.Cmd
- func GetConfiguredEditor() string
- func GetFont(code bool, font string) string
- func HostDirectory(c *cli.Context) (string, error)
- func IsDev() bool
- func IsTor(c *cli.Context) bool
- func Language(c *cli.Context, auto bool) string
- func LoadUser(c *cli.Context) (*writeas.AuthUser, error)
- func MessageRetryCompose(fname string) string
- func SaveConfig(dataDir string, uc *Config) error
- func SaveUser(c *cli.Context, u *writeas.AuthUser) error
- func TorPort(c *cli.Context) int
- func TorURL(c *cli.Context) string
- func UserAgent(c *cli.Context) string
- func UserDataDir(dataDirName string) string
- func UserHostDir(c *cli.Context) (string, error)
- type APIConfig
- type Config
- type DefaultConfig
- type PostsConfig
Constants ¶
const ( PostFontNormal postFont = "norm" PostFontSans = "sans" PostFontMono = "mono" PostFontWrap = "wrap" PostFontCode = "code" )
Valid appearance types for posts.
const ( // Defaults for posts on Write.as. DefaultFont = PostFontMono WriteasBaseURL = "https://write.as" DevBaseURL = "https://development.write.as" TorBaseURL = "http://writeas7pm7rcdqg.onion" )
Application constants.
const (
// ConfigFile is the full filename for application configuration files
ConfigFile = "config.ini"
)
const (
NoEditorErr = "Couldn't find default editor. Try setting $EDITOR environment variable in ~/.profile"
)
Variables ¶
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 CurrentUser ¶
CurrentUser returns the username of the user taking action in the current cli.Context.
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 GetConfiguredEditor ¶
func GetConfiguredEditor() string
func HostDirectory ¶
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 MessageRetryCompose ¶
func SaveConfig ¶
func UserDataDir ¶
UserDataDir returns a platform specific directory under the user's home directory
func UserHostDir ¶
UserHostDir returns the path to the user data directory with the host based subpath if the host flag is set
Types ¶
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 ¶
type DefaultConfig ¶
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