Package flags defines command-line flags to make them consistent between binaries. Not all flags make sense for all binaries.
var ( // BlockSize ("blocksize") is the block size used when writing large files. // The default is 1MB; it can be no larger than 1GB. BlockSize = defaultBlockSize // CacheDir ("cachedir") specifies the directory for the various file // caches. CacheDir = defaultCacheDir // CacheSize ("cachesize") specifies the maximum bytes used by // the various file caches. This is only approximate. CacheSize = defaultCacheSize // Config ("config") names the Upspin configuration file to use. Config = defaultConfig // HTTPAddr ("http") is the network address on which to listen for // incoming insecure network connections. HTTPAddr = defaultHTTPAddr // HTTPSAddr ("https") is the network address on which to listen for // incoming secure network connections. HTTPSAddr = defaultHTTPSAddr // InsecureHTTP ("insecure") specifies whether to serve insecure HTTP // on HTTPAddr, instead of serving HTTPS (secured by TLS) on HTTPSAddr. InsecureHTTP = false // LetsEncryptCache ("letscache") is the location of a file in which // the Let's Encrypt certificates are stored. The containing directory // should be owner-accessible only (chmod 0700). LetsEncryptCache = defaultLetsEncryptCache // Log ("log") sets the level of logging (implements flag.Value). Log logFlag // NetAddr ("addr") is the publicly accessible network address of this // server. NetAddr = "" // ServerConfig ("serverconfig") specifies configuration options for // servers in "key=value" pairs. ServerConfig string // ServerKind ("kind") is the implementation kind of this server. ServerKind = defaultServerKind // Prudent ("prudent") sets an extra security mode in the client to // check for malicious or buggy servers, at possible cost in // performance or convenience. Specifically, one check is that the // writer listed in a directory entry is either the owner or a user // currently with write permission. This protects against a forged // directory entry at the cost of potentially blocking a legitimate // file written by a user who no longer has write permission. Prudent = false // TLSCertFile and TLSKeyFile ("tls") specify the location of a TLS // certificate/key pair used for serving TLS (HTTPS). TLSCertFile = "" TLSKeyFile = "" // Version causes the program to print its release version and exit. // The printed version is only meaningful in released binaries. Version = false )
The Parse and Register functions bind these variables to their respective command-line flags.
Client is the set of flags most useful in clients. It can be passed as the argument to Parse to set up the package for a client.
None is the set of no flags. It is rarely needed as most programs use either the Server or Client set.
Server is the set of flags most useful in servers. It can be passed as the argument to Parse to set up the package for a server.
Args returns a slice of -flag=value strings that will recreate the state of the flags. Flags set to their default value are elided.
Parse registers the command-line flags for the given default flags list, plus any extra flag names, and calls flag.Parse. Passing no flag names in either list registers all flags. Passing an unknown name triggers a panic. The Server and Client variables contain useful default sets.
flags.Parse(flags.Client) // Register all client flags. flags.Parse(flags.Server, "cachedir") // Register all server flags plus cachedir. flags.Parse(nil) // Register all flags. flags.Parse(flags.None, "config", "endpoint") // Register only config and endpoint.
ParseArgs is the same as Parse but uses the provided argument list instead of those provided on the command line. For ParseArgs, the initial command name should not be provided.
ParseArgsInto is the same as ParseArgs but accepts a FlagSet argument instead of using the default flag.CommandLine FlagSet.
ParseInto is the same as Parse but accepts a FlagSet argument instead of using the default flag.CommandLine FlagSet.
Register registers the command-line flags for the given flag names. Unlike Parse, it may be called multiple times. Passing zero names install all flags. Passing an unknown name triggers a panic.
flags.Register("config", "endpoint") // Register Config and Endpoint.
flags.Register() // Register all flags.
RegisterInto is the same as Register but accepts a FlagSet argument instead of using the default flag.CommandLine FlagSet.