Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InstallBashCompletion ¶
InstallBashCompletion install bash_completion
Types ¶
type CSVRecord ¶
type CSVRecord struct {
// contains filtered or unexported fields
}
CSV reads one csv record
type Duration ¶
Duration wrap time.Duration
Example ¶
This example demonstrates uage of Duration decoder
package main
import (
"github.com/akeylesslabs/cli"
"github.com/akeylesslabs/cli/ext"
)
func main() {
type argT struct {
Duration ext.Duration `cli:"d"`
}
for _, args := range [][]string{
[]string{"app", "-d10s"},
[]string{"app", "-d10ms"},
} {
cli.RunWithArgs(new(argT), args, func(ctx *cli.Context) error {
argv := ctx.Argv().(*argT)
ctx.String("duration=%v\n", argv.Duration.Duration)
return nil
})
}
}
Output: duration=10s duration=10ms
type File ¶
type File struct {
// contains filtered or unexported fields
}
File reads data from file or stdin(if filename is empty)
Example ¶
This example demonstrates usage of File decoder
package main
import (
"io/ioutil"
"os"
"github.com/akeylesslabs/cli"
"github.com/akeylesslabs/cli/ext"
)
func main() {
type argT struct {
Data ext.File `cli:"f"`
}
filename := "test.txt"
ioutil.WriteFile(filename, []byte("hello, File decoder"), 0644)
defer os.Remove(filename)
args := []string{"app", "-f", filename}
cli.RunWithArgs(new(argT), args, func(ctx *cli.Context) error {
argv := ctx.Argv().(*argT)
ctx.String("%s\n", argv.Data)
return nil
})
}
Output: hello, File decoder
type Reader ¶ added in v0.0.2
type Reader struct {
// contains filtered or unexported fields
}
Reader
type Time ¶
Time wrap time.Time
Example ¶
This example demonstrates usage of Time decoder
package main
import (
"time"
"github.com/akeylesslabs/cli"
"github.com/akeylesslabs/cli/ext"
)
func main() {
type argT struct {
When ext.Time `cli:"w"`
}
for _, args := range [][]string{
[]string{"app", "-w", "2016-01-02 12:12:22"},
[]string{"app", "-w2016-01-02"},
} {
cli.RunWithArgs(new(argT), args, func(ctx *cli.Context) error {
argv := ctx.Argv().(*argT)
ctx.String("time=%s\n", argv.When.Time.Format(time.ANSIC))
return nil
})
}
}
Output: time=Sat Jan 2 12:12:22 2016 time=Sat Jan 2 00:00:00 2016
Click to show internal directories.
Click to hide internal directories.