Documentation
¶
Index ¶
- Constants
- func Exit(err error)
- func ExitStatus(err error) int
- func Flags(ctx context.Context) *pflag.FlagSet
- func GetContext(cmd *cobra.Command) context.Context
- func GetTarget(ctx context.Context) string
- func HeadDumper(ctx context.Context) io.WriteCloser
- func Input(ctx context.Context) io.ReadCloser
- func Output(ctx context.Context) io.Writer
- func SetConf(ctx context.Context, conf *Config) context.Context
- func SetContext(ctx context.Context, cmd *cobra.Command)
- func SetFlags(ctx context.Context, flags *pflag.FlagSet) context.Context
- func SetHeadDumper(ctx context.Context, d io.WriteCloser) context.Context
- func SetInput(ctx context.Context, w io.ReadCloser) context.Context
- func SetOutput(ctx context.Context, w io.Writer) context.Context
- func SetTarget(ctx context.Context, target string) context.Context
- func SetVerbose(ctx context.Context, value bool) context.Context
- func TargetHelpText(scope TargetScope) string
- func TargetScopeName(scope TargetScope) string
- func Verbose(ctx context.Context) bool
- type Config
- type Context
- type InitError
- type NamedContext
- type Options
- type Target
- type TargetScope
Constants ¶
const ( // Curl-equivalent flags FlagVerbose = "verbose" FlagOutputFile = "output" FlagData = "data" FlagHead = "head" FlagDumpHeader = "dump-header" FlagUser = "user" FlagCreateDirs = "create-dirs" // Custom flags FlagClobber = "force" FlagConfigFile = "kouchconfig" FlagServerRoot = "root" FlagDataJSON = "data-json" FlagDataYAML = "data-yaml" FlagOutputFormat = "output-format" FlagFilename = "filename" FlagDocument = "id" FlagDatabase = "database" FlagFullCommit = "full-commit" FlagIfNoneMatch = "if-none-match" FlagRev = "rev" FlagAutoRev = "auto-rev" FlagShards = "shards" FlagPassword = "password" FlagContext = "context" FlagConflicts = "conflicts" FlagDescending = "descending" FlagEndKey = "endkey" FlagEndKeyDocID = "endkey-docid" FlagGroup = "group" FlagGroupLevel = "group-level" FlagIncludeDocs = "include-docs" FlagIncludeAttachments = "attachments" FlagIncludeAttEncoding = "att-encoding-info" FlagInclusiveEnd = "inclusive-end" FlagKey = "key" FlagKeys = "keys" FlagLimit = "limit" FlagReduce = "reduce" FlagSkip = "skip" FlagSorted = "sorted" FlagStable = "stable" FlagStale = "stale" FlagStartKey = "startkey" FlagStartKeyDocID = "startkey-docid" FlagUpdate = "update" FlagUpdateSeq = "update-seq" FlagTemplate = "template" FlagTemplateFile = "template-file" FlagJSONPrefix = "json-prefix" FlagJSONIndent = "json-indent" FlagJSONEscapeHTML = "json-escape-html" FlagAttsSince = "atts-since" FlagIncludeDeletedConflicts = "deleted-conflicts" FlagForceLatest = "latest" FlagIncludeLocalSeq = "local-seq" FlagMeta = "meta" FlagOpenRevs = "open-revs" FlagRevs = "revs" FlagRevsInfo = "revs-info" FlagBatch = "batch" FlagNewEdits = "new-edits" // Curl-equivalent short flags FlagShortVerbose = "v" FlagShortOutputFile = "o" FlagShortData = "d" FlagShortHead = "I" FlagShortDumpHeader = "D" FlagShortUser = "u" // Short versions, custom FlagShortServerRoot = "S" FlagShortOutputFormat = "F" FlagShortRev = "r" FlagShortAutoRev = "R" FlagShortShards = "q" FlagShortPassword = "p" )
Common command line flags
const Version = "0.0.1-prerelease"
Version is the version of this release of Kouch.
Variables ¶
This section is empty.
Functions ¶
func Exit ¶
func Exit(err error)
Exit outputs err.Error() to stderr, then exits with the exit status embedded in the error.
func ExitStatus ¶
ExitStatus returns the exit status embedded in the error.
func GetContext ¶
GetContext returns the context associated with cmd.
func HeadDumper ¶
func HeadDumper(ctx context.Context) io.WriteCloser
HeadDumper returns an io.Writer to which headers should be written, or nil if none.
func Input ¶
func Input(ctx context.Context) io.ReadCloser
Input returns the context's current input, or panics if none is set.
func SetContext ¶
SetContext sets the context associated with the command.
func SetHeadDumper ¶
SetHeadDumper returns a new context with the head-dumper set to d.
func SetVerbose ¶
SetVerbose returns a new context with the Verbose flag set to value.
func TargetHelpText ¶
func TargetHelpText(scope TargetScope) string
TargetHelpText returns the help text to describe the valid target format(s) for the specified scope, or "" if the scope isn't defined.
func TargetScopeName ¶
func TargetScopeName(scope TargetScope) string
TargetScopeName returns the name of the scope, or "" if scope is invalid.
Types ¶
type Config ¶
type Config struct { // DefaultContext is the name of the context to be used by default. DefaultContext string `yaml:"default-context" json:"default-context,omitempty"` // Contexts is a map of referencable names to context configs Contexts []NamedContext `json:"contexts,omitempty"` // File is the file where config was read from, or more precisely, where // changes will be saved to. File string `json:"-" yaml:"-"` }
Config represents the kouch tool configuration.
func (*Config) DefaultCtx ¶
DefaultCtx returns the default context.
func (*Config) Dump ¶
func (c *Config) Dump() (r io.ReadCloser)
Dump dumps the config as a JSON string on r. Any errors will be returned as an error on r.Read().
type Context ¶
type Context struct { // Root is the URL to the server's root. Root string `json:"root"` User string `json:"user,omitempty"` Password string `json:"password,omitempty"` }
Context is a server context (URL, auth info, session store, etc)
type InitError ¶
type InitError string
InitError returns an error for init failures.
func (InitError) ExitStatus ¶
ExitStatus returns ExitFailedToInitialize
type NamedContext ¶
type NamedContext struct { // Name is the nickname for this Context Name string `json:"name"` // Context holds the context information Context *Context `json:"context"` }
NamedContext relates nicknames to context information.
type Options ¶
Options represents the accumulated options passed by the user, through config files, the commandline, etc.
type Target ¶
type Target struct { // Root is the root URL. Root string // Database is the database name. Database string // DocID is the document ID. Document string // Filename is the attachment filename. Filename string // User is the Auth username User string // Password is the Auth password Password string }
Target is a parsed target passed on the command line.
func ParseTarget ¶
func ParseTarget(scope TargetScope, src string) (*Target, error)
ParseTarget parses src as a CouchDB target, according to the rules for scope.
func (*Target) DatabaseFromFlags ¶
DatabaseFromFlags sets t.Database from the passed flagset.
func (*Target) DocumentFromFlags ¶
DocumentFromFlags sets t.DocID from the passed flagset.
func (*Target) FilenameFromFlags ¶
FilenameFromFlags sets t.Filename from the passed flagset.
type TargetScope ¶
type TargetScope int
TargetScope represents the scope for a target, as relative targets have different meanings in different contexts.
const ( TargetRoot TargetScope = iota TargetDatabase TargetDocument TargetAttachment )
The supported target scopes
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
cmd
|
|
internal
|
|
test
Package test provides test utilities
|
Package test provides test utilities |
util
Package util contains random junk, for internal use only.
|
Package util contains random junk, for internal use only. |
Package kouchio provides basic I/O primitives meant to suppliment the standard library's io package.
|
Package kouchio provides basic I/O primitives meant to suppliment the standard library's io package. |