Documentation
¶
Index ¶
Constants ¶
const ( PathOrReaderType = "$pathOrReader" PathOrWriterType = "$pathOrWriter" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Bytes ¶
type Bytes []byte
Bytes is a string meant to hold a slice of bytes. - as a string: `{ "bucket": "name", "object": "/path/to/file" }` - as a reference to a file: "@dir/file" - from piped input: "-"
type FilePath ¶
type FilePath string
FilePath represents a file path and provides with helper to open / create either regular files or pipe stdin / stdout whenever the path is '-'.
type Json ¶
type Json string
Json is a string meant to hold a json value. - as a string: `{ "bucket": "name", "object": "/path/to/file" }` - as a reference to a file: "@dir/file" - from piped input: "-"
func (Json) Interface ¶ added in v1.0.2
Interface unmarshals this JSON string into an empty interface{}. If the string value starts with '@', it looks for a file with that name and uses the content of the file.
type PathOrReader ¶
PathOrReader implements flag.Value such as it can be used as an attribute in another struct and used with bflags bindings.
This allows the same struct to be used for command line parameter as well as in programmatic use.
**notes**
- the path attributes _must_ be initialized otherwise bindings will error In the example below: `tr := &TestReader{Path: &PathOrReader{}}`
- the attribute MUST be a pointer not a value (*PathOrReader not PathOrReader)
Example
type TestReader struct {
Name string `cmd:"flag"`
Path *PathOrReader `cmd:"flag"`
}
func (*PathOrReader) CanRead ¶
func (p *PathOrReader) CanRead() bool
func (*PathOrReader) Open ¶
func (p *PathOrReader) Open() (Reader, error)
func (*PathOrReader) Set ¶
func (p *PathOrReader) Set(path string) error
func (*PathOrReader) String ¶
func (p *PathOrReader) String() string
func (*PathOrReader) Type ¶
func (p *PathOrReader) Type() string
type PathOrWriter ¶
PathOrWriter implements flag.Value such as it can be used as an attribute in another struct and used with bflags bindings.
This allows the same struct to be used for command line parameter as well as in programmatic use.
**notes** - a PathOrWriter attribute _must_ be initialized for bindings to work. - the attribute MUST be a pointer not a value (*PathOrWriter not PathOrWriter)
see PathOrReader for an example.
func (*PathOrWriter) CanWrite ¶
func (p *PathOrWriter) CanWrite() bool
func (*PathOrWriter) Create ¶
func (p *PathOrWriter) Create() (Writer, error)
func (*PathOrWriter) Set ¶
func (p *PathOrWriter) Set(path string) error
func (*PathOrWriter) String ¶
func (p *PathOrWriter) String() string
func (*PathOrWriter) Type ¶
func (p *PathOrWriter) Type() string