├── .travis.yml ├── vendor ├── github.com │ ├── mattn │ │ ├── go-isatty │ │ │ ├── doc.go │ │ │ ├── isatty_appengine.go │ │ │ ├── isatty_linux.go │ │ │ ├── isatty_solaris.go │ │ │ ├── isatty_bsd.go │ │ │ ├── isatty_windows.go │ │ │ └── LICENSE │ │ └── go-colorable │ │ │ ├── colorable_others.go │ │ │ ├── LICENSE │ │ │ └── noncolorable.go │ ├── cheggaaa │ │ └── pb │ │ │ ├── pb_solaris.go │ │ │ ├── pb_nix.go │ │ │ ├── termios_nix.go │ │ │ ├── termios_bsd.go │ │ │ ├── pb_appengine.go │ │ │ ├── runecount.go │ │ │ ├── pool_x.go │ │ │ ├── reader.go │ │ │ ├── pool_win.go │ │ │ ├── LICENSE │ │ │ ├── pool.go │ │ │ ├── format.go │ │ │ └── pb_x.go │ ├── kr │ │ ├── text │ │ │ ├── doc.go │ │ │ ├── License │ │ │ ├── mc │ │ │ │ └── mc.go │ │ │ ├── indent.go │ │ │ ├── cmd │ │ │ │ └── agg │ │ │ │ │ ├── string.go │ │ │ │ │ ├── num.go │ │ │ │ │ ├── main.go │ │ │ │ │ └── doc.go │ │ │ └── wrap.go │ │ ├── pty │ │ │ ├── types.go │ │ │ ├── ztypes_386.go │ │ │ ├── ztypes_arm.go │ │ │ ├── ztypes_amd64.go │ │ │ ├── ztypes_arm64.go │ │ │ ├── ztypes_ppc64.go │ │ │ ├── ztypes_s390x.go │ │ │ ├── ztypes_ppc64le.go │ │ │ ├── pty_unsupported.go │ │ │ ├── ztypes_freebsd_386.go │ │ │ ├── ztypes_freebsd_arm.go │ │ │ ├── ioctl.go │ │ │ ├── ztypes_freebsd_amd64.go │ │ │ ├── types_freebsd.go │ │ │ ├── ztypes_dragonfly_amd64.go │ │ │ ├── types_dragonfly.go │ │ │ ├── doc.go │ │ │ ├── run.go │ │ │ ├── util.go │ │ │ ├── pty_linux.go │ │ │ ├── License │ │ │ ├── ioctl_bsd.go │ │ │ ├── pty_darwin.go │ │ │ ├── pty_freebsd.go │ │ │ └── pty_dragonfly.go │ │ └── pretty │ │ │ ├── License │ │ │ └── zero.go │ ├── urfave │ │ └── cli │ │ │ ├── altsrc │ │ │ ├── altsrc.go │ │ │ ├── input_source_context.go │ │ │ └── yaml_file_loader.go │ │ │ ├── cli.go │ │ │ ├── LICENSE │ │ │ ├── category.go │ │ │ ├── funcs.go │ │ │ └── errors.go │ ├── codegangsta │ │ └── cli │ │ │ ├── altsrc │ │ │ ├── altsrc.go │ │ │ ├── input_source_context.go │ │ │ └── yaml_file_loader.go │ │ │ ├── cli.go │ │ │ ├── LICENSE │ │ │ ├── category.go │ │ │ ├── funcs.go │ │ │ └── errors.go │ ├── dustin │ │ └── go-humanize │ │ │ ├── humanize.go │ │ │ ├── ordinals.go │ │ │ ├── ftoa.go │ │ │ ├── big.go │ │ │ ├── commaf.go │ │ │ ├── LICENSE │ │ │ ├── comma.go │ │ │ ├── si.go │ │ │ └── bytes.go │ ├── BurntSushi │ │ └── toml │ │ │ ├── COPYING │ │ │ ├── encoding_types_1.1.go │ │ │ ├── encoding_types.go │ │ │ ├── doc.go │ │ │ ├── cmd │ │ │ ├── tomlv │ │ │ │ └── main.go │ │ │ └── toml-test-decoder │ │ │ │ └── main.go │ │ │ └── type_check.go │ ├── op │ │ └── go-logging │ │ │ ├── syslog_fallback.go │ │ │ ├── backend.go │ │ │ ├── LICENSE │ │ │ ├── examples │ │ │ └── example.go │ │ │ ├── syslog.go │ │ │ ├── multi.go │ │ │ └── log_nix.go │ └── fatih │ │ └── color │ │ └── LICENSE.md ├── gopkg.in │ ├── cheggaaa │ │ └── pb.v1 │ │ │ ├── pb_solaris.go │ │ │ ├── pb_nix.go │ │ │ ├── termios_nix.go │ │ │ ├── termios_bsd.go │ │ │ ├── pb_appengine.go │ │ │ ├── runecount.go │ │ │ ├── pool_x.go │ │ │ ├── reader.go │ │ │ ├── pool_win.go │ │ │ ├── LICENSE │ │ │ ├── pool.go │ │ │ ├── format.go │ │ │ └── pb_x.go │ ├── yaml.v2 │ │ ├── LICENSE │ │ ├── writerc.go │ │ └── sorter.go │ └── check.v1 │ │ ├── LICENSE │ │ └── reporter.go └── golang.org │ └── x │ └── sys │ └── unix │ ├── asm.s │ ├── constants.go │ ├── syscall_no_getwd.go │ ├── zsysnum_solaris_amd64.go │ ├── env_unset.go │ ├── flock_linux_32bit.go │ ├── asm_solaris_amd64.s │ ├── gccgo_linux_amd64.go │ ├── race0.go │ ├── env_unix.go │ ├── asm_linux_arm64.s │ ├── str.go │ ├── race.go │ ├── asm_linux_s390x.s │ ├── asm_linux_ppc64x.s │ ├── asm_linux_arm.s │ ├── asm_linux_mips64x.s │ ├── asm_freebsd_arm.s │ ├── asm_netbsd_arm.s │ ├── asm_darwin_386.s │ ├── asm_freebsd_386.s │ ├── asm_netbsd_386.s │ ├── asm_openbsd_386.s │ ├── asm_darwin_amd64.s │ ├── asm_freebsd_amd64.s │ ├── asm_linux_amd64.s │ ├── asm_netbsd_amd64.s │ ├── asm_openbsd_amd64.s │ ├── asm_dragonfly_amd64.s │ ├── asm_darwin_arm.s │ ├── bluetooth_linux.go │ ├── asm_darwin_arm64.s │ ├── flock.go │ ├── asm_linux_386.s │ ├── syscall_solaris_amd64.go │ ├── syscall_openbsd_amd64.go │ ├── syscall_netbsd_386.go │ ├── syscall_netbsd_arm.go │ ├── syscall_netbsd_amd64.go │ ├── syscall_openbsd_386.go │ ├── gccgo_c.c │ ├── sockcmsg_linux.go │ ├── LICENSE │ ├── syscall_dragonfly_amd64.go │ ├── syscall_freebsd_amd64.go │ ├── syscall_freebsd_arm.go │ ├── syscall_freebsd_386.go │ ├── gccgo.go │ ├── mkpost.go │ ├── syscall_darwin_arm.go │ ├── syscall_darwin_arm64.go │ ├── syscall_darwin_386.go │ ├── syscall_darwin_amd64.go │ └── syscall.go ├── main.go ├── .gitignore ├── console └── console.go ├── json ├── tags_test.go ├── tags.go └── tagkey_test.go └── cmd ├── search_test.go ├── flags.go ├── template.go ├── cluster.go ├── templates.go └── search.go /.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go: 3 | - release 4 | - tip 5 | 6 | script: 7 | - go test -v ./... 8 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/doc.go: -------------------------------------------------------------------------------- 1 | // Package isatty implements interface to isatty 2 | package isatty 3 | -------------------------------------------------------------------------------- /vendor/github.com/cheggaaa/pb/pb_solaris.go: -------------------------------------------------------------------------------- 1 | // +build solaris 2 | // +build !appengine 3 | 4 | package pb 5 | 6 | const sysIoctl = 54 7 | -------------------------------------------------------------------------------- /vendor/gopkg.in/cheggaaa/pb.v1/pb_solaris.go: -------------------------------------------------------------------------------- 1 | // +build solaris 2 | // +build !appengine 3 | 4 | package pb 5 | 6 | const sysIoctl = 54 7 | -------------------------------------------------------------------------------- /vendor/github.com/kr/text/doc.go: -------------------------------------------------------------------------------- 1 | // Package text provides rudimentary functions for manipulating text in 2 | // paragraphs. 3 | package text 4 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/types.go: -------------------------------------------------------------------------------- 1 | // +build ignore 2 | 3 | package pty 4 | 5 | import "C" 6 | 7 | type ( 8 | _C_int C.int 9 | _C_uint C.uint 10 | ) 11 | -------------------------------------------------------------------------------- /vendor/github.com/urfave/cli/altsrc/altsrc.go: -------------------------------------------------------------------------------- 1 | package altsrc 2 | 3 | //go:generate python ../generate-flag-types altsrc -i ../flag-types.json -o flag_generated.go 4 | -------------------------------------------------------------------------------- /vendor/github.com/codegangsta/cli/altsrc/altsrc.go: -------------------------------------------------------------------------------- 1 | package altsrc 2 | 3 | //go:generate python ../generate-flag-types altsrc -i ../flag-types.json -o flag_generated.go 4 | -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "os" 5 | 6 | "github.com/dutchcoders/elastico/cmd" 7 | ) 8 | 9 | func main() { 10 | app := cmd.NewApp() 11 | app.Run(os.Args) 12 | } 13 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/ztypes_386.go: -------------------------------------------------------------------------------- 1 | // Created by cgo -godefs - DO NOT EDIT 2 | // cgo -godefs types.go 3 | 4 | package pty 5 | 6 | type ( 7 | _C_int int32 8 | _C_uint uint32 9 | ) 10 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/ztypes_arm.go: -------------------------------------------------------------------------------- 1 | // Created by cgo -godefs - DO NOT EDIT 2 | // cgo -godefs types.go 3 | 4 | package pty 5 | 6 | type ( 7 | _C_int int32 8 | _C_uint uint32 9 | ) 10 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/ztypes_amd64.go: -------------------------------------------------------------------------------- 1 | // Created by cgo -godefs - DO NOT EDIT 2 | // cgo -godefs types.go 3 | 4 | package pty 5 | 6 | type ( 7 | _C_int int32 8 | _C_uint uint32 9 | ) 10 | -------------------------------------------------------------------------------- /vendor/github.com/cheggaaa/pb/pb_nix.go: -------------------------------------------------------------------------------- 1 | // +build linux darwin freebsd netbsd openbsd dragonfly 2 | // +build !appengine 3 | 4 | package pb 5 | 6 | import "syscall" 7 | 8 | const sysIoctl = syscall.SYS_IOCTL 9 | -------------------------------------------------------------------------------- /vendor/gopkg.in/cheggaaa/pb.v1/pb_nix.go: -------------------------------------------------------------------------------- 1 | // +build linux darwin freebsd netbsd openbsd dragonfly 2 | // +build !appengine 3 | 4 | package pb 5 | 6 | import "syscall" 7 | 8 | const sysIoctl = syscall.SYS_IOCTL 9 | -------------------------------------------------------------------------------- /vendor/github.com/cheggaaa/pb/termios_nix.go: -------------------------------------------------------------------------------- 1 | // +build linux solaris 2 | // +build !appengine 3 | 4 | package pb 5 | 6 | const ioctlReadTermios = 0x5401 // syscall.TCGETS 7 | const ioctlWriteTermios = 0x5402 // syscall.TCSETS 8 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/ztypes_arm64.go: -------------------------------------------------------------------------------- 1 | // Created by cgo -godefs - DO NOT EDIT 2 | // cgo -godefs types.go 3 | 4 | // +build arm64 5 | 6 | package pty 7 | 8 | type ( 9 | _C_int int32 10 | _C_uint uint32 11 | ) 12 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/ztypes_ppc64.go: -------------------------------------------------------------------------------- 1 | // +build ppc64 2 | 3 | // Created by cgo -godefs - DO NOT EDIT 4 | // cgo -godefs types.go 5 | 6 | package pty 7 | 8 | type ( 9 | _C_int int32 10 | _C_uint uint32 11 | ) 12 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/ztypes_s390x.go: -------------------------------------------------------------------------------- 1 | // +build s390x 2 | 3 | // Created by cgo -godefs - DO NOT EDIT 4 | // cgo -godefs types.go 5 | 6 | package pty 7 | 8 | type ( 9 | _C_int int32 10 | _C_uint uint32 11 | ) 12 | -------------------------------------------------------------------------------- /vendor/gopkg.in/cheggaaa/pb.v1/termios_nix.go: -------------------------------------------------------------------------------- 1 | // +build linux solaris 2 | // +build !appengine 3 | 4 | package pb 5 | 6 | const ioctlReadTermios = 0x5401 // syscall.TCGETS 7 | const ioctlWriteTermios = 0x5402 // syscall.TCSETS 8 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/ztypes_ppc64le.go: -------------------------------------------------------------------------------- 1 | // +build ppc64le 2 | 3 | // Created by cgo -godefs - DO NOT EDIT 4 | // cgo -godefs types.go 5 | 6 | package pty 7 | 8 | type ( 9 | _C_int int32 10 | _C_uint uint32 11 | ) 12 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/pty_unsupported.go: -------------------------------------------------------------------------------- 1 | // +build !linux,!darwin,!freebsd,!dragonfly 2 | 3 | package pty 4 | 5 | import ( 6 | "os" 7 | ) 8 | 9 | func open() (pty, tty *os.File, err error) { 10 | return nil, nil, ErrUnsupported 11 | } 12 | -------------------------------------------------------------------------------- /vendor/github.com/cheggaaa/pb/termios_bsd.go: -------------------------------------------------------------------------------- 1 | // +build darwin freebsd netbsd openbsd dragonfly 2 | // +build !appengine 3 | 4 | package pb 5 | 6 | import "syscall" 7 | 8 | const ioctlReadTermios = syscall.TIOCGETA 9 | const ioctlWriteTermios = syscall.TIOCSETA 10 | -------------------------------------------------------------------------------- /vendor/gopkg.in/cheggaaa/pb.v1/termios_bsd.go: -------------------------------------------------------------------------------- 1 | // +build darwin freebsd netbsd openbsd dragonfly 2 | // +build !appengine 3 | 4 | package pb 5 | 6 | import "syscall" 7 | 8 | const ioctlReadTermios = syscall.TIOCGETA 9 | const ioctlWriteTermios = syscall.TIOCSETA 10 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/ztypes_freebsd_386.go: -------------------------------------------------------------------------------- 1 | // Created by cgo -godefs - DO NOT EDIT 2 | // cgo -godefs types_freebsd.go 3 | 4 | package pty 5 | 6 | const ( 7 | _C_SPECNAMELEN = 0x3f 8 | ) 9 | 10 | type fiodgnameArg struct { 11 | Len int32 12 | Buf *byte 13 | } 14 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/ztypes_freebsd_arm.go: -------------------------------------------------------------------------------- 1 | // Created by cgo -godefs - DO NOT EDIT 2 | // cgo -godefs types_freebsd.go 3 | 4 | package pty 5 | 6 | const ( 7 | _C_SPECNAMELEN = 0x3f 8 | ) 9 | 10 | type fiodgnameArg struct { 11 | Len int32 12 | Buf *byte 13 | } 14 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/ioctl.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | 3 | package pty 4 | 5 | import "syscall" 6 | 7 | func ioctl(fd, cmd, ptr uintptr) error { 8 | _, _, e := syscall.Syscall(syscall.SYS_IOCTL, fd, cmd, ptr) 9 | if e != 0 { 10 | return e 11 | } 12 | return nil 13 | } 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | TEXT ·use(SB),NOSPLIT,$0 10 | RET 11 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/ztypes_freebsd_amd64.go: -------------------------------------------------------------------------------- 1 | // Created by cgo -godefs - DO NOT EDIT 2 | // cgo -godefs types_freebsd.go 3 | 4 | package pty 5 | 6 | const ( 7 | _C_SPECNAMELEN = 0x3f 8 | ) 9 | 10 | type fiodgnameArg struct { 11 | Len int32 12 | Pad_cgo_0 [4]byte 13 | Buf *byte 14 | } 15 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/types_freebsd.go: -------------------------------------------------------------------------------- 1 | // +build ignore 2 | 3 | package pty 4 | 5 | /* 6 | #include 7 | #include 8 | */ 9 | import "C" 10 | 11 | const ( 12 | _C_SPECNAMELEN = C.SPECNAMELEN /* max length of devicename */ 13 | ) 14 | 15 | type fiodgnameArg C.struct_fiodgname_arg 16 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/ztypes_dragonfly_amd64.go: -------------------------------------------------------------------------------- 1 | // Created by cgo -godefs - DO NOT EDIT 2 | // cgo -godefs types_dragonfly.go 3 | 4 | package pty 5 | 6 | const ( 7 | _C_SPECNAMELEN = 0x3f 8 | ) 9 | 10 | type fiodgnameArg struct { 11 | Name *byte 12 | Len uint32 13 | Pad_cgo_0 [4]byte 14 | } 15 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/isatty_appengine.go: -------------------------------------------------------------------------------- 1 | // +build appengine 2 | 3 | package isatty 4 | 5 | // IsTerminal returns true if the file descriptor is terminal which 6 | // is always false on on appengine classic which is a sandboxed PaaS. 7 | func IsTerminal(fd uintptr) bool { 8 | return false 9 | } 10 | -------------------------------------------------------------------------------- /vendor/github.com/dustin/go-humanize/humanize.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package humanize converts boring ugly numbers to human-friendly strings and back. 3 | 4 | Durations can be turned into strings such as "3 days ago", numbers 5 | representing sizes like 82854982 into useful strings like, "83MB" or 6 | "79MiB" (whichever you prefer). 7 | */ 8 | package humanize 9 | -------------------------------------------------------------------------------- /vendor/github.com/cheggaaa/pb/pb_appengine.go: -------------------------------------------------------------------------------- 1 | // +build appengine 2 | 3 | package pb 4 | 5 | import "errors" 6 | 7 | // terminalWidth returns width of the terminal, which is not supported 8 | // and should always failed on appengine classic which is a sandboxed PaaS. 9 | func terminalWidth() (int, error) { 10 | return 0, errors.New("Not supported") 11 | } 12 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/types_dragonfly.go: -------------------------------------------------------------------------------- 1 | // +build ignore 2 | 3 | package pty 4 | 5 | /* 6 | #define _KERNEL 7 | #include 8 | #include 9 | #include 10 | */ 11 | import "C" 12 | 13 | const ( 14 | _C_SPECNAMELEN = C.SPECNAMELEN /* max length of devicename */ 15 | ) 16 | 17 | type fiodgnameArg C.struct_fiodname_args 18 | -------------------------------------------------------------------------------- /vendor/gopkg.in/cheggaaa/pb.v1/pb_appengine.go: -------------------------------------------------------------------------------- 1 | // +build appengine 2 | 3 | package pb 4 | 5 | import "errors" 6 | 7 | // terminalWidth returns width of the terminal, which is not supported 8 | // and should always failed on appengine classic which is a sandboxed PaaS. 9 | func terminalWidth() (int, error) { 10 | return 0, errors.New("Not supported") 11 | } 12 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/constants.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | package unix 8 | 9 | const ( 10 | R_OK = 0x4 11 | W_OK = 0x2 12 | X_OK = 0x1 13 | ) 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Folders 7 | _obj 8 | _test 9 | 10 | # Architecture specific extensions/prefixes 11 | *.[568vq] 12 | [568vq].out 13 | 14 | *.cgo1.go 15 | *.cgo2.c 16 | _cgo_defun.c 17 | _cgo_gotypes.go 18 | _cgo_export.* 19 | 20 | _testmain.go 21 | 22 | *.exe 23 | *.test 24 | *.prof 25 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_no_getwd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build dragonfly freebsd netbsd openbsd 6 | 7 | package unix 8 | 9 | const ImplementsGetwd = false 10 | 11 | func Getwd() (string, error) { return "", ENOTSUP } 12 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/zsysnum_solaris_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,solaris 6 | 7 | package unix 8 | 9 | // TODO(aram): remove these before Go 1.3. 10 | const ( 11 | SYS_EXECVE = 59 12 | SYS_FCNTL = 62 13 | ) 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/env_unset.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build go1.4 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | func Unsetenv(key string) error { 12 | // This was added in Go 1.4. 13 | return syscall.Unsetenv(key) 14 | } 15 | -------------------------------------------------------------------------------- /vendor/github.com/cheggaaa/pb/runecount.go: -------------------------------------------------------------------------------- 1 | package pb 2 | 3 | import ( 4 | "regexp" 5 | "unicode/utf8" 6 | ) 7 | 8 | // Finds the control character sequences (like colors) 9 | var ctrlFinder = regexp.MustCompile("\x1b\x5b[0-9]+\x6d") 10 | 11 | func escapeAwareRuneCountInString(s string) int { 12 | n := utf8.RuneCountInString(s) 13 | for _, sm := range ctrlFinder.FindAllString(s, -1) { 14 | n -= len(sm) 15 | } 16 | return n 17 | } 18 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/doc.go: -------------------------------------------------------------------------------- 1 | // Package pty provides functions for working with Unix terminals. 2 | package pty 3 | 4 | import ( 5 | "errors" 6 | "os" 7 | ) 8 | 9 | // ErrUnsupported is returned if a function is not 10 | // available on the current platform. 11 | var ErrUnsupported = errors.New("unsupported") 12 | 13 | // Opens a pty and its corresponding tty. 14 | func Open() (pty, tty *os.File, err error) { 15 | return open() 16 | } 17 | -------------------------------------------------------------------------------- /vendor/gopkg.in/cheggaaa/pb.v1/runecount.go: -------------------------------------------------------------------------------- 1 | package pb 2 | 3 | import ( 4 | "regexp" 5 | "unicode/utf8" 6 | ) 7 | 8 | // Finds the control character sequences (like colors) 9 | var ctrlFinder = regexp.MustCompile("\x1b\x5b[0-9]+\x6d") 10 | 11 | func escapeAwareRuneCountInString(s string) int { 12 | n := utf8.RuneCountInString(s) 13 | for _, sm := range ctrlFinder.FindAllString(s, -1) { 14 | n -= len(sm) 15 | } 16 | return n 17 | } 18 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/flock_linux_32bit.go: -------------------------------------------------------------------------------- 1 | // +build linux,386 linux,arm 2 | 3 | // Copyright 2014 The Go Authors. All rights reserved. 4 | // Use of this source code is governed by a BSD-style 5 | // license that can be found in the LICENSE file. 6 | 7 | package unix 8 | 9 | func init() { 10 | // On 32-bit Linux systems, the fcntl syscall that matches Go's 11 | // Flock_t type is SYS_FCNTL64, not SYS_FCNTL. 12 | fcntl64Syscall = SYS_FCNTL64 13 | } 14 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-colorable/colorable_others.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | 3 | package colorable 4 | 5 | import ( 6 | "io" 7 | "os" 8 | ) 9 | 10 | func NewColorable(file *os.File) io.Writer { 11 | if file == nil { 12 | panic("nil passed instead of *os.File to NewColorable()") 13 | } 14 | 15 | return file 16 | } 17 | 18 | func NewColorableStdout() io.Writer { 19 | return os.Stdout 20 | } 21 | 22 | func NewColorableStderr() io.Writer { 23 | return os.Stderr 24 | } 25 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/isatty_linux.go: -------------------------------------------------------------------------------- 1 | // +build linux 2 | // +build !appengine 3 | 4 | package isatty 5 | 6 | import ( 7 | "syscall" 8 | "unsafe" 9 | ) 10 | 11 | const ioctlReadTermios = syscall.TCGETS 12 | 13 | // IsTerminal return true if the file descriptor is terminal. 14 | func IsTerminal(fd uintptr) bool { 15 | var termios syscall.Termios 16 | _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0) 17 | return err == 0 18 | } 19 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/isatty_solaris.go: -------------------------------------------------------------------------------- 1 | // +build solaris 2 | // +build !appengine 3 | 4 | package isatty 5 | 6 | import ( 7 | "golang.org/x/sys/unix" 8 | ) 9 | 10 | // IsTerminal returns true if the given file descriptor is a terminal. 11 | // see: http://src.illumos.org/source/xref/illumos-gate/usr/src/lib/libbc/libc/gen/common/isatty.c 12 | func IsTerminal(fd uintptr) bool { 13 | var termio unix.Termio 14 | err := unix.IoctlSetTermio(int(fd), unix.TCGETA, &termio) 15 | return err == nil 16 | } 17 | -------------------------------------------------------------------------------- /vendor/github.com/dustin/go-humanize/ordinals.go: -------------------------------------------------------------------------------- 1 | package humanize 2 | 3 | import "strconv" 4 | 5 | // Ordinal gives you the input number in a rank/ordinal format. 6 | // 7 | // Ordinal(3) -> 3rd 8 | func Ordinal(x int) string { 9 | suffix := "th" 10 | switch x % 10 { 11 | case 1: 12 | if x%100 != 11 { 13 | suffix = "st" 14 | } 15 | case 2: 16 | if x%100 != 12 { 17 | suffix = "nd" 18 | } 19 | case 3: 20 | if x%100 != 13 { 21 | suffix = "rd" 22 | } 23 | } 24 | return strconv.Itoa(x) + suffix 25 | } 26 | -------------------------------------------------------------------------------- /vendor/github.com/cheggaaa/pb/pool_x.go: -------------------------------------------------------------------------------- 1 | // +build linux darwin freebsd netbsd openbsd solaris dragonfly 2 | 3 | package pb 4 | 5 | import "fmt" 6 | 7 | func (p *Pool) print(first bool) bool { 8 | var out string 9 | if !first { 10 | out = fmt.Sprintf("\033[%dA", len(p.bars)) 11 | } 12 | isFinished := true 13 | for _, bar := range p.bars { 14 | if !bar.isFinish { 15 | isFinished = false 16 | } 17 | bar.Update() 18 | out += fmt.Sprintf("\r%s\n", bar.String()) 19 | } 20 | fmt.Print(out) 21 | return isFinished 22 | } 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_solaris_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for amd64, Solaris are implemented in runtime/syscall_solaris.go 11 | // 12 | 13 | TEXT ·sysvicall6(SB),NOSPLIT,$0-64 14 | JMP syscall·sysvicall6(SB) 15 | 16 | TEXT ·rawSysvicall6(SB),NOSPLIT,$0-64 17 | JMP syscall·rawSysvicall6(SB) 18 | -------------------------------------------------------------------------------- /vendor/gopkg.in/cheggaaa/pb.v1/pool_x.go: -------------------------------------------------------------------------------- 1 | // +build linux darwin freebsd netbsd openbsd solaris dragonfly 2 | 3 | package pb 4 | 5 | import "fmt" 6 | 7 | func (p *Pool) print(first bool) bool { 8 | var out string 9 | if !first { 10 | out = fmt.Sprintf("\033[%dA", len(p.bars)) 11 | } 12 | isFinished := true 13 | for _, bar := range p.bars { 14 | if !bar.isFinish { 15 | isFinished = false 16 | } 17 | bar.Update() 18 | out += fmt.Sprintf("\r%s\n", bar.String()) 19 | } 20 | fmt.Print(out) 21 | return isFinished 22 | } 23 | -------------------------------------------------------------------------------- /vendor/github.com/dustin/go-humanize/ftoa.go: -------------------------------------------------------------------------------- 1 | package humanize 2 | 3 | import "strconv" 4 | 5 | func stripTrailingZeros(s string) string { 6 | offset := len(s) - 1 7 | for offset > 0 { 8 | if s[offset] == '.' { 9 | offset-- 10 | break 11 | } 12 | if s[offset] != '0' { 13 | break 14 | } 15 | offset-- 16 | } 17 | return s[:offset+1] 18 | } 19 | 20 | // Ftoa converts a float to a string with no trailing zeros. 21 | func Ftoa(num float64) string { 22 | return stripTrailingZeros(strconv.FormatFloat(num, 'f', 6, 64)) 23 | } 24 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/isatty_bsd.go: -------------------------------------------------------------------------------- 1 | // +build darwin freebsd openbsd netbsd dragonfly 2 | // +build !appengine 3 | 4 | package isatty 5 | 6 | import ( 7 | "syscall" 8 | "unsafe" 9 | ) 10 | 11 | const ioctlReadTermios = syscall.TIOCGETA 12 | 13 | // IsTerminal return true if the file descriptor is terminal. 14 | func IsTerminal(fd uintptr) bool { 15 | var termios syscall.Termios 16 | _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0) 17 | return err == 0 18 | } 19 | -------------------------------------------------------------------------------- /vendor/github.com/cheggaaa/pb/reader.go: -------------------------------------------------------------------------------- 1 | package pb 2 | 3 | import ( 4 | "io" 5 | ) 6 | 7 | // It's proxy reader, implement io.Reader 8 | type Reader struct { 9 | io.Reader 10 | bar *ProgressBar 11 | } 12 | 13 | func (r *Reader) Read(p []byte) (n int, err error) { 14 | n, err = r.Reader.Read(p) 15 | r.bar.Add(n) 16 | return 17 | } 18 | 19 | // Close the reader when it implements io.Closer 20 | func (r *Reader) Close() (err error) { 21 | if closer, ok := r.Reader.(io.Closer); ok { 22 | return closer.Close() 23 | } 24 | return 25 | } 26 | -------------------------------------------------------------------------------- /vendor/gopkg.in/cheggaaa/pb.v1/reader.go: -------------------------------------------------------------------------------- 1 | package pb 2 | 3 | import ( 4 | "io" 5 | ) 6 | 7 | // It's proxy reader, implement io.Reader 8 | type Reader struct { 9 | io.Reader 10 | bar *ProgressBar 11 | } 12 | 13 | func (r *Reader) Read(p []byte) (n int, err error) { 14 | n, err = r.Reader.Read(p) 15 | r.bar.Add(n) 16 | return 17 | } 18 | 19 | // Close the reader when it implements io.Closer 20 | func (r *Reader) Close() (err error) { 21 | if closer, ok := r.Reader.(io.Closer); ok { 22 | return closer.Close() 23 | } 24 | return 25 | } 26 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/isatty_windows.go: -------------------------------------------------------------------------------- 1 | // +build windows 2 | // +build !appengine 3 | 4 | package isatty 5 | 6 | import ( 7 | "syscall" 8 | "unsafe" 9 | ) 10 | 11 | var kernel32 = syscall.NewLazyDLL("kernel32.dll") 12 | var procGetConsoleMode = kernel32.NewProc("GetConsoleMode") 13 | 14 | // IsTerminal return true if the file descriptor is terminal. 15 | func IsTerminal(fd uintptr) bool { 16 | var st uint32 17 | r, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, fd, uintptr(unsafe.Pointer(&st)), 0) 18 | return r != 0 && e == 0 19 | } 20 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/gccgo_linux_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build gccgo,linux,amd64 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | //extern gettimeofday 12 | func realGettimeofday(*Timeval, *byte) int32 13 | 14 | func gettimeofday(tv *Timeval) (err syscall.Errno) { 15 | r := realGettimeofday(tv, nil) 16 | if r < 0 { 17 | return syscall.GetErrno() 18 | } 19 | return 0 20 | } 21 | -------------------------------------------------------------------------------- /vendor/github.com/BurntSushi/toml/COPYING: -------------------------------------------------------------------------------- 1 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 2 | Version 2, December 2004 3 | 4 | Copyright (C) 2004 Sam Hocevar 5 | 6 | Everyone is permitted to copy and distribute verbatim or modified 7 | copies of this license document, and changing it is allowed as long 8 | as the name is changed. 9 | 10 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 11 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 12 | 13 | 0. You just DO WHAT THE FUCK YOU WANT TO. 14 | 15 | -------------------------------------------------------------------------------- /console/console.go: -------------------------------------------------------------------------------- 1 | package console 2 | 3 | import ( 4 | "bufio" 5 | "fmt" 6 | "os" 7 | "strings" 8 | ) 9 | 10 | var DefaultConsole = New() 11 | 12 | func Scanln(ask string, args ...interface{}) (string, error) { 13 | return DefaultConsole.Scanln(ask, args...) 14 | } 15 | 16 | func New() *Console { 17 | return &Console{} 18 | } 19 | 20 | type Console struct { 21 | } 22 | 23 | func (c *Console) Scanln(ask string, args ...interface{}) (string, error) { 24 | r := bufio.NewReader(os.Stdin) 25 | fmt.Printf(ask, args...) 26 | 27 | input, err := r.ReadString('\n') 28 | return strings.TrimSpace(input), err 29 | } 30 | -------------------------------------------------------------------------------- /vendor/github.com/BurntSushi/toml/encoding_types_1.1.go: -------------------------------------------------------------------------------- 1 | // +build !go1.2 2 | 3 | package toml 4 | 5 | // These interfaces were introduced in Go 1.2, so we add them manually when 6 | // compiling for Go 1.1. 7 | 8 | // TextMarshaler is a synonym for encoding.TextMarshaler. It is defined here 9 | // so that Go 1.1 can be supported. 10 | type TextMarshaler interface { 11 | MarshalText() (text []byte, err error) 12 | } 13 | 14 | // TextUnmarshaler is a synonym for encoding.TextUnmarshaler. It is defined 15 | // here so that Go 1.1 can be supported. 16 | type TextUnmarshaler interface { 17 | UnmarshalText(text []byte) error 18 | } 19 | -------------------------------------------------------------------------------- /vendor/gopkg.in/yaml.v2/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2011-2016 Canonical Ltd. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/race0.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin,!race linux,!race freebsd,!race netbsd openbsd solaris dragonfly 6 | 7 | package unix 8 | 9 | import ( 10 | "unsafe" 11 | ) 12 | 13 | const raceenabled = false 14 | 15 | func raceAcquire(addr unsafe.Pointer) { 16 | } 17 | 18 | func raceReleaseMerge(addr unsafe.Pointer) { 19 | } 20 | 21 | func raceReadRange(addr unsafe.Pointer, len int) { 22 | } 23 | 24 | func raceWriteRange(addr unsafe.Pointer, len int) { 25 | } 26 | -------------------------------------------------------------------------------- /vendor/github.com/BurntSushi/toml/encoding_types.go: -------------------------------------------------------------------------------- 1 | // +build go1.2 2 | 3 | package toml 4 | 5 | // In order to support Go 1.1, we define our own TextMarshaler and 6 | // TextUnmarshaler types. For Go 1.2+, we just alias them with the 7 | // standard library interfaces. 8 | 9 | import ( 10 | "encoding" 11 | ) 12 | 13 | // TextMarshaler is a synonym for encoding.TextMarshaler. It is defined here 14 | // so that Go 1.1 can be supported. 15 | type TextMarshaler encoding.TextMarshaler 16 | 17 | // TextUnmarshaler is a synonym for encoding.TextUnmarshaler. It is defined 18 | // here so that Go 1.1 can be supported. 19 | type TextUnmarshaler encoding.TextUnmarshaler 20 | -------------------------------------------------------------------------------- /vendor/github.com/urfave/cli/altsrc/input_source_context.go: -------------------------------------------------------------------------------- 1 | package altsrc 2 | 3 | import ( 4 | "time" 5 | 6 | "github.com/urfave/cli" 7 | ) 8 | 9 | // InputSourceContext is an interface used to allow 10 | // other input sources to be implemented as needed. 11 | type InputSourceContext interface { 12 | Int(name string) (int, error) 13 | Duration(name string) (time.Duration, error) 14 | Float64(name string) (float64, error) 15 | String(name string) (string, error) 16 | StringSlice(name string) ([]string, error) 17 | IntSlice(name string) ([]int, error) 18 | Generic(name string) (cli.Generic, error) 19 | Bool(name string) (bool, error) 20 | BoolT(name string) (bool, error) 21 | } 22 | -------------------------------------------------------------------------------- /vendor/github.com/codegangsta/cli/altsrc/input_source_context.go: -------------------------------------------------------------------------------- 1 | package altsrc 2 | 3 | import ( 4 | "time" 5 | 6 | "github.com/urfave/cli" 7 | ) 8 | 9 | // InputSourceContext is an interface used to allow 10 | // other input sources to be implemented as needed. 11 | type InputSourceContext interface { 12 | Int(name string) (int, error) 13 | Duration(name string) (time.Duration, error) 14 | Float64(name string) (float64, error) 15 | String(name string) (string, error) 16 | StringSlice(name string) ([]string, error) 17 | IntSlice(name string) ([]int, error) 18 | Generic(name string) (cli.Generic, error) 19 | Bool(name string) (bool, error) 20 | BoolT(name string) (bool, error) 21 | } 22 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/env_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | // Unix environment variables. 8 | 9 | package unix 10 | 11 | import "syscall" 12 | 13 | func Getenv(key string) (value string, found bool) { 14 | return syscall.Getenv(key) 15 | } 16 | 17 | func Setenv(key, value string) error { 18 | return syscall.Setenv(key, value) 19 | } 20 | 21 | func Clearenv() { 22 | syscall.Clearenv() 23 | } 24 | 25 | func Environ() []string { 26 | return syscall.Environ() 27 | } 28 | -------------------------------------------------------------------------------- /json/tags_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package json 6 | 7 | import ( 8 | "testing" 9 | ) 10 | 11 | func TestTagParsing(t *testing.T) { 12 | name, opts := parseTag("field,foobar,foo") 13 | if name != "field" { 14 | t.Fatalf("name = %q, want field", name) 15 | } 16 | for _, tt := range []struct { 17 | opt string 18 | want bool 19 | }{ 20 | {"foobar", true}, 21 | {"foo", true}, 22 | {"bar", false}, 23 | } { 24 | if opts.Contains(tt.opt) != tt.want { 25 | t.Errorf("Contains(%q) = %v", tt.opt, !tt.want) 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /vendor/github.com/cheggaaa/pb/pool_win.go: -------------------------------------------------------------------------------- 1 | // +build windows 2 | 3 | package pb 4 | 5 | import ( 6 | "fmt" 7 | "log" 8 | ) 9 | 10 | func (p *Pool) print(first bool) bool { 11 | var out string 12 | if !first { 13 | coords, err := getCursorPos() 14 | if err != nil { 15 | log.Panic(err) 16 | } 17 | coords.Y -= int16(len(p.bars)) 18 | coords.X = 0 19 | 20 | err = setCursorPos(coords) 21 | if err != nil { 22 | log.Panic(err) 23 | } 24 | } 25 | isFinished := true 26 | for _, bar := range p.bars { 27 | if !bar.isFinish { 28 | isFinished = false 29 | } 30 | bar.Update() 31 | out += fmt.Sprintf("\r%s\n", bar.String()) 32 | } 33 | fmt.Print(out) 34 | return isFinished 35 | } 36 | -------------------------------------------------------------------------------- /vendor/gopkg.in/cheggaaa/pb.v1/pool_win.go: -------------------------------------------------------------------------------- 1 | // +build windows 2 | 3 | package pb 4 | 5 | import ( 6 | "fmt" 7 | "log" 8 | ) 9 | 10 | func (p *Pool) print(first bool) bool { 11 | var out string 12 | if !first { 13 | coords, err := getCursorPos() 14 | if err != nil { 15 | log.Panic(err) 16 | } 17 | coords.Y -= int16(len(p.bars)) 18 | coords.X = 0 19 | 20 | err = setCursorPos(coords) 21 | if err != nil { 22 | log.Panic(err) 23 | } 24 | } 25 | isFinished := true 26 | for _, bar := range p.bars { 27 | if !bar.isFinish { 28 | isFinished = false 29 | } 30 | bar.Update() 31 | out += fmt.Sprintf("\r%s\n", bar.String()) 32 | } 33 | fmt.Print(out) 34 | return isFinished 35 | } 36 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_arm64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux 6 | // +build arm64 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // Just jump to package syscall's implementation for all these functions. 12 | // The runtime may know about them. 13 | 14 | TEXT ·Syscall(SB),NOSPLIT,$0-56 15 | B syscall·Syscall(SB) 16 | 17 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 18 | B syscall·Syscall6(SB) 19 | 20 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 21 | B syscall·RawSyscall(SB) 22 | 23 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 24 | B syscall·RawSyscall6(SB) 25 | -------------------------------------------------------------------------------- /cmd/search_test.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "flag" 5 | "testing" 6 | 7 | elastico "elastico" 8 | 9 | "github.com/codegangsta/cli" 10 | ) 11 | 12 | func TestSearch(t *testing.T) { 13 | // setup("test-index", "test-type") 14 | app := cli.NewApp() 15 | if val, err := elastico.New("http://127.0.0.1:9200/"); err != nil { 16 | t.Fatal(err) 17 | } else { 18 | e = val 19 | } 20 | 21 | globalSet := flag.NewFlagSet("test", 0) 22 | globalSet.Set("index", "remco2") 23 | globalSet.Set("type", "remco2") 24 | globalCtx := cli.NewContext(app, globalSet, nil) 25 | 26 | set := flag.NewFlagSet("test", 0) 27 | set.Parse([]string{"-size", "10"}) 28 | 29 | c := cli.NewContext(nil, set, globalCtx) 30 | 31 | run(runSearch)(c) 32 | } 33 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/str.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | package unix 8 | 9 | func itoa(val int) string { // do it here rather than with fmt to avoid dependency 10 | if val < 0 { 11 | return "-" + uitoa(uint(-val)) 12 | } 13 | return uitoa(uint(val)) 14 | } 15 | 16 | func uitoa(val uint) string { 17 | var buf [32]byte // big enough for int64 18 | i := len(buf) - 1 19 | for val >= 10 { 20 | buf[i] = byte(val%10 + '0') 21 | i-- 22 | val /= 10 23 | } 24 | buf[i] = byte(val + '0') 25 | return string(buf[i:]) 26 | } 27 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/race.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin,race linux,race freebsd,race 6 | 7 | package unix 8 | 9 | import ( 10 | "runtime" 11 | "unsafe" 12 | ) 13 | 14 | const raceenabled = true 15 | 16 | func raceAcquire(addr unsafe.Pointer) { 17 | runtime.RaceAcquire(addr) 18 | } 19 | 20 | func raceReleaseMerge(addr unsafe.Pointer) { 21 | runtime.RaceReleaseMerge(addr) 22 | } 23 | 24 | func raceReadRange(addr unsafe.Pointer, len int) { 25 | runtime.RaceReadRange(addr, len) 26 | } 27 | 28 | func raceWriteRange(addr unsafe.Pointer, len int) { 29 | runtime.RaceWriteRange(addr, len) 30 | } 31 | -------------------------------------------------------------------------------- /vendor/github.com/dustin/go-humanize/big.go: -------------------------------------------------------------------------------- 1 | package humanize 2 | 3 | import ( 4 | "math/big" 5 | ) 6 | 7 | // order of magnitude (to a max order) 8 | func oomm(n, b *big.Int, maxmag int) (float64, int) { 9 | mag := 0 10 | m := &big.Int{} 11 | for n.Cmp(b) >= 0 { 12 | n.DivMod(n, b, m) 13 | mag++ 14 | if mag == maxmag && maxmag >= 0 { 15 | break 16 | } 17 | } 18 | return float64(n.Int64()) + (float64(m.Int64()) / float64(b.Int64())), mag 19 | } 20 | 21 | // total order of magnitude 22 | // (same as above, but with no upper limit) 23 | func oom(n, b *big.Int) (float64, int) { 24 | mag := 0 25 | m := &big.Int{} 26 | for n.Cmp(b) >= 0 { 27 | n.DivMod(n, b, m) 28 | mag++ 29 | } 30 | return float64(n.Int64()) + (float64(m.Int64()) / float64(b.Int64())), mag 31 | } 32 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_s390x.s: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build s390x 6 | // +build linux 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for s390x, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-56 19 | BR syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 22 | BR syscall·Syscall6(SB) 23 | 24 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 25 | BR syscall·RawSyscall(SB) 26 | 27 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 28 | BR syscall·RawSyscall6(SB) 29 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_ppc64x.s: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux 6 | // +build ppc64 ppc64le 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for ppc64, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-56 19 | BR syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 22 | BR syscall·Syscall6(SB) 23 | 24 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 25 | BR syscall·RawSyscall(SB) 26 | 27 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 28 | BR syscall·RawSyscall6(SB) 29 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/run.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | 3 | package pty 4 | 5 | import ( 6 | "os" 7 | "os/exec" 8 | "syscall" 9 | ) 10 | 11 | // Start assigns a pseudo-terminal tty os.File to c.Stdin, c.Stdout, 12 | // and c.Stderr, calls c.Start, and returns the File of the tty's 13 | // corresponding pty. 14 | func Start(c *exec.Cmd) (pty *os.File, err error) { 15 | pty, tty, err := Open() 16 | if err != nil { 17 | return nil, err 18 | } 19 | defer tty.Close() 20 | c.Stdout = tty 21 | c.Stdin = tty 22 | c.Stderr = tty 23 | if c.SysProcAttr == nil { 24 | c.SysProcAttr = &syscall.SysProcAttr{} 25 | } 26 | c.SysProcAttr.Setctty = true 27 | c.SysProcAttr.Setsid = true 28 | err = c.Start() 29 | if err != nil { 30 | pty.Close() 31 | return nil, err 32 | } 33 | return pty, err 34 | } 35 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for arm, Linux 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 23 | B syscall·RawSyscall(SB) 24 | 25 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 26 | B syscall·RawSyscall6(SB) 27 | 28 | TEXT ·seek(SB),NOSPLIT,$0-32 29 | B syscall·seek(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_mips64x.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux 6 | // +build mips64 mips64le 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for mips64, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-56 19 | JMP syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 22 | JMP syscall·Syscall6(SB) 23 | 24 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 25 | JMP syscall·RawSyscall(SB) 26 | 27 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 28 | JMP syscall·RawSyscall6(SB) 29 | -------------------------------------------------------------------------------- /vendor/github.com/urfave/cli/cli.go: -------------------------------------------------------------------------------- 1 | // Package cli provides a minimal framework for creating and organizing command line 2 | // Go applications. cli is designed to be easy to understand and write, the most simple 3 | // cli application can be written as follows: 4 | // func main() { 5 | // cli.NewApp().Run(os.Args) 6 | // } 7 | // 8 | // Of course this application does not do much, so let's make this an actual application: 9 | // func main() { 10 | // app := cli.NewApp() 11 | // app.Name = "greet" 12 | // app.Usage = "say a greeting" 13 | // app.Action = func(c *cli.Context) error { 14 | // println("Greetings") 15 | // } 16 | // 17 | // app.Run(os.Args) 18 | // } 19 | package cli 20 | 21 | //go:generate python ./generate-flag-types cli -i flag-types.json -o flag_generated.go 22 | -------------------------------------------------------------------------------- /vendor/github.com/codegangsta/cli/cli.go: -------------------------------------------------------------------------------- 1 | // Package cli provides a minimal framework for creating and organizing command line 2 | // Go applications. cli is designed to be easy to understand and write, the most simple 3 | // cli application can be written as follows: 4 | // func main() { 5 | // cli.NewApp().Run(os.Args) 6 | // } 7 | // 8 | // Of course this application does not do much, so let's make this an actual application: 9 | // func main() { 10 | // app := cli.NewApp() 11 | // app.Name = "greet" 12 | // app.Usage = "say a greeting" 13 | // app.Action = func(c *cli.Context) error { 14 | // println("Greetings") 15 | // } 16 | // 17 | // app.Run(os.Args) 18 | // } 19 | package cli 20 | 21 | //go:generate python ./generate-flag-types cli -i flag-types.json -o flag_generated.go 22 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_freebsd_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for ARM, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | B syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | B syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | B syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_netbsd_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for ARM, NetBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | B syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | B syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | B syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, Darwin 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_freebsd_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_netbsd_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, NetBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_openbsd_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, OpenBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/util.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | 3 | package pty 4 | 5 | import ( 6 | "os" 7 | "syscall" 8 | "unsafe" 9 | ) 10 | 11 | // Getsize returns the number of rows (lines) and cols (positions 12 | // in each line) in terminal t. 13 | func Getsize(t *os.File) (rows, cols int, err error) { 14 | var ws winsize 15 | err = windowrect(&ws, t.Fd()) 16 | return int(ws.ws_row), int(ws.ws_col), err 17 | } 18 | 19 | type winsize struct { 20 | ws_row uint16 21 | ws_col uint16 22 | ws_xpixel uint16 23 | ws_ypixel uint16 24 | } 25 | 26 | func windowrect(ws *winsize, fd uintptr) error { 27 | _, _, errno := syscall.Syscall( 28 | syscall.SYS_IOCTL, 29 | fd, 30 | syscall.TIOCGWINSZ, 31 | uintptr(unsafe.Pointer(ws)), 32 | ) 33 | if errno != 0 { 34 | return syscall.Errno(errno) 35 | } 36 | return nil 37 | } 38 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, Darwin 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_freebsd_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for AMD64, Linux 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 23 | JMP syscall·RawSyscall(SB) 24 | 25 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 26 | JMP syscall·RawSyscall6(SB) 27 | 28 | TEXT ·gettimeofday(SB),NOSPLIT,$0-16 29 | JMP syscall·gettimeofday(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_netbsd_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, NetBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_openbsd_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, OpenBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_dragonfly_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, DragonFly 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-64 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-88 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-112 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-64 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-88 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | // +build arm,darwin 7 | 8 | #include "textflag.h" 9 | 10 | // 11 | // System call support for ARM, Darwin 12 | // 13 | 14 | // Just jump to package syscall's implementation for all these functions. 15 | // The runtime may know about them. 16 | 17 | TEXT ·Syscall(SB),NOSPLIT,$0-28 18 | B syscall·Syscall(SB) 19 | 20 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 21 | B syscall·Syscall6(SB) 22 | 23 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 24 | B syscall·Syscall9(SB) 25 | 26 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 27 | B syscall·RawSyscall(SB) 28 | 29 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 30 | B syscall·RawSyscall6(SB) 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/bluetooth_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Bluetooth sockets and messages 6 | 7 | package unix 8 | 9 | // Bluetooth Protocols 10 | const ( 11 | BTPROTO_L2CAP = 0 12 | BTPROTO_HCI = 1 13 | BTPROTO_SCO = 2 14 | BTPROTO_RFCOMM = 3 15 | BTPROTO_BNEP = 4 16 | BTPROTO_CMTP = 5 17 | BTPROTO_HIDP = 6 18 | BTPROTO_AVDTP = 7 19 | ) 20 | 21 | const ( 22 | HCI_CHANNEL_RAW = 0 23 | HCI_CHANNEL_USER = 1 24 | HCI_CHANNEL_MONITOR = 2 25 | HCI_CHANNEL_CONTROL = 3 26 | ) 27 | 28 | // Socketoption Level 29 | const ( 30 | SOL_BLUETOOTH = 0x112 31 | SOL_HCI = 0x0 32 | SOL_L2CAP = 0x6 33 | SOL_RFCOMM = 0x12 34 | SOL_SCO = 0x11 35 | ) 36 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_arm64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | // +build arm64,darwin 7 | 8 | #include "textflag.h" 9 | 10 | // 11 | // System call support for AMD64, Darwin 12 | // 13 | 14 | // Just jump to package syscall's implementation for all these functions. 15 | // The runtime may know about them. 16 | 17 | TEXT ·Syscall(SB),NOSPLIT,$0-56 18 | B syscall·Syscall(SB) 19 | 20 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 21 | B syscall·Syscall6(SB) 22 | 23 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 24 | B syscall·Syscall9(SB) 25 | 26 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 27 | B syscall·RawSyscall(SB) 28 | 29 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 30 | B syscall·RawSyscall6(SB) 31 | -------------------------------------------------------------------------------- /vendor/github.com/op/go-logging/syslog_fallback.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013, Örjan Persson. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //+build windows plan9 6 | 7 | package logging 8 | 9 | import ( 10 | "fmt" 11 | ) 12 | 13 | type Priority int 14 | 15 | type SyslogBackend struct { 16 | } 17 | 18 | func NewSyslogBackend(prefix string) (b *SyslogBackend, err error) { 19 | return nil, fmt.Errorf("Platform does not support syslog") 20 | } 21 | 22 | func NewSyslogBackendPriority(prefix string, priority Priority) (b *SyslogBackend, err error) { 23 | return nil, fmt.Errorf("Platform does not support syslog") 24 | } 25 | 26 | func (b *SyslogBackend) Log(level Level, calldepth int, rec *Record) error { 27 | return fmt.Errorf("Platform does not support syslog") 28 | } 29 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/flock.go: -------------------------------------------------------------------------------- 1 | // +build linux darwin freebsd openbsd netbsd dragonfly 2 | 3 | // Copyright 2014 The Go Authors. All rights reserved. 4 | // Use of this source code is governed by a BSD-style 5 | // license that can be found in the LICENSE file. 6 | 7 | // +build darwin dragonfly freebsd linux netbsd openbsd 8 | 9 | package unix 10 | 11 | import "unsafe" 12 | 13 | // fcntl64Syscall is usually SYS_FCNTL, but is overridden on 32-bit Linux 14 | // systems by flock_linux_32bit.go to be SYS_FCNTL64. 15 | var fcntl64Syscall uintptr = SYS_FCNTL 16 | 17 | // FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command. 18 | func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error { 19 | _, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(unsafe.Pointer(lk))) 20 | if errno == 0 { 21 | return nil 22 | } 23 | return errno 24 | } 25 | -------------------------------------------------------------------------------- /vendor/github.com/dustin/go-humanize/commaf.go: -------------------------------------------------------------------------------- 1 | // +build go1.6 2 | 3 | package humanize 4 | 5 | import ( 6 | "bytes" 7 | "math/big" 8 | "strings" 9 | ) 10 | 11 | // BigCommaf produces a string form of the given big.Float in base 10 12 | // with commas after every three orders of magnitude. 13 | func BigCommaf(v *big.Float) string { 14 | buf := &bytes.Buffer{} 15 | if v.Sign() < 0 { 16 | buf.Write([]byte{'-'}) 17 | v.Abs(v) 18 | } 19 | 20 | comma := []byte{','} 21 | 22 | parts := strings.Split(v.Text('f', -1), ".") 23 | pos := 0 24 | if len(parts[0])%3 != 0 { 25 | pos += len(parts[0]) % 3 26 | buf.WriteString(parts[0][:pos]) 27 | buf.Write(comma) 28 | } 29 | for ; pos < len(parts[0]); pos += 3 { 30 | buf.WriteString(parts[0][pos : pos+3]) 31 | buf.Write(comma) 32 | } 33 | buf.Truncate(buf.Len() - 1) 34 | 35 | if len(parts) > 1 { 36 | buf.Write([]byte{'.'}) 37 | buf.WriteString(parts[1]) 38 | } 39 | return buf.String() 40 | } 41 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for 386, Linux 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 23 | JMP syscall·RawSyscall(SB) 24 | 25 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 26 | JMP syscall·RawSyscall6(SB) 27 | 28 | TEXT ·socketcall(SB),NOSPLIT,$0-36 29 | JMP syscall·socketcall(SB) 30 | 31 | TEXT ·rawsocketcall(SB),NOSPLIT,$0-36 32 | JMP syscall·rawsocketcall(SB) 33 | 34 | TEXT ·seek(SB),NOSPLIT,$0-28 35 | JMP syscall·seek(SB) 36 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_solaris_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,solaris 6 | 7 | package unix 8 | 9 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 10 | 11 | func NsecToTimespec(nsec int64) (ts Timespec) { 12 | ts.Sec = nsec / 1e9 13 | ts.Nsec = nsec % 1e9 14 | return 15 | } 16 | 17 | func NsecToTimeval(nsec int64) (tv Timeval) { 18 | nsec += 999 // round up to microsecond 19 | tv.Usec = nsec % 1e9 / 1e3 20 | tv.Sec = int64(nsec / 1e9) 21 | return 22 | } 23 | 24 | func (iov *Iovec) SetLen(length int) { 25 | iov.Len = uint64(length) 26 | } 27 | 28 | func (cmsg *Cmsghdr) SetLen(length int) { 29 | cmsg.Len = uint32(length) 30 | } 31 | 32 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 33 | // TODO(aram): implement this, see issue 5847. 34 | panic("unimplemented") 35 | } 36 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/pty_linux.go: -------------------------------------------------------------------------------- 1 | package pty 2 | 3 | import ( 4 | "os" 5 | "strconv" 6 | "syscall" 7 | "unsafe" 8 | ) 9 | 10 | func open() (pty, tty *os.File, err error) { 11 | p, err := os.OpenFile("/dev/ptmx", os.O_RDWR, 0) 12 | if err != nil { 13 | return nil, nil, err 14 | } 15 | 16 | sname, err := ptsname(p) 17 | if err != nil { 18 | return nil, nil, err 19 | } 20 | 21 | err = unlockpt(p) 22 | if err != nil { 23 | return nil, nil, err 24 | } 25 | 26 | t, err := os.OpenFile(sname, os.O_RDWR|syscall.O_NOCTTY, 0) 27 | if err != nil { 28 | return nil, nil, err 29 | } 30 | return p, t, nil 31 | } 32 | 33 | func ptsname(f *os.File) (string, error) { 34 | var n _C_uint 35 | err := ioctl(f.Fd(), syscall.TIOCGPTN, uintptr(unsafe.Pointer(&n))) 36 | if err != nil { 37 | return "", err 38 | } 39 | return "/dev/pts/" + strconv.Itoa(int(n)), nil 40 | } 41 | 42 | func unlockpt(f *os.File) error { 43 | var u _C_int 44 | // use TIOCSPTLCK with a zero valued arg to clear the slave pty lock 45 | return ioctl(f.Fd(), syscall.TIOCSPTLCK, uintptr(unsafe.Pointer(&u))) 46 | } 47 | -------------------------------------------------------------------------------- /vendor/github.com/kr/text/License: -------------------------------------------------------------------------------- 1 | Copyright 2012 Keith Rarick 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) Yasuhiro MATSUMOTO 2 | 3 | MIT License (Expat) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_openbsd_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,openbsd 6 | 7 | package unix 8 | 9 | func Getpagesize() int { return 4096 } 10 | 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | func NsecToTimespec(nsec int64) (ts Timespec) { 14 | ts.Sec = nsec / 1e9 15 | ts.Nsec = nsec % 1e9 16 | return 17 | } 18 | 19 | func NsecToTimeval(nsec int64) (tv Timeval) { 20 | nsec += 999 // round up to microsecond 21 | tv.Usec = nsec % 1e9 / 1e3 22 | tv.Sec = nsec / 1e9 23 | return 24 | } 25 | 26 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 27 | k.Ident = uint64(fd) 28 | k.Filter = int16(mode) 29 | k.Flags = uint16(flags) 30 | } 31 | 32 | func (iov *Iovec) SetLen(length int) { 33 | iov.Len = uint64(length) 34 | } 35 | 36 | func (msghdr *Msghdr) SetControllen(length int) { 37 | msghdr.Controllen = uint32(length) 38 | } 39 | 40 | func (cmsg *Cmsghdr) SetLen(length int) { 41 | cmsg.Len = uint32(length) 42 | } 43 | -------------------------------------------------------------------------------- /cmd/flags.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import "github.com/codegangsta/cli" 4 | 5 | var IndexFlag = cli.StringFlag{ 6 | Name: "index", 7 | Value: "_all", 8 | } 9 | 10 | type RequiredFlag struct { 11 | cli.Flag 12 | } 13 | 14 | func (rsf RequiredFlag) Required() bool { 15 | return true 16 | } 17 | 18 | func Required(flag cli.Flag) cli.Flag { 19 | return RequiredFlag{ 20 | flag, 21 | } 22 | } 23 | 24 | var ( 25 | IndexRequiredFlag = RequiredFlag{ 26 | cli.StringFlag{ 27 | Name: "index", 28 | Value: "", 29 | EnvVar: "ELASTICO_INDEX", 30 | }, 31 | } 32 | TypeRequiredFlag = RequiredFlag{ 33 | cli.StringFlag{ 34 | Name: "type", 35 | Value: "", 36 | EnvVar: "ELASTICO_TYPE", 37 | }, 38 | } 39 | TemplateRequiredFlag = RequiredFlag{ 40 | cli.StringFlag{ 41 | Name: "template", 42 | Value: "", 43 | EnvVar: "", 44 | }, 45 | } 46 | FieldRequiredFlag = RequiredFlag{ 47 | cli.StringFlag{ 48 | Name: "field", 49 | Value: "", 50 | }, 51 | } 52 | TypeFlag = cli.StringFlag{ 53 | Name: "type", 54 | Value: "", 55 | } 56 | 57 | FieldFlag = cli.StringFlag{ 58 | Name: "field", 59 | Value: "", 60 | } 61 | ) 62 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/License: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011 Keith Rarick 2 | 3 | Permission is hereby granted, free of charge, to any person 4 | obtaining a copy of this software and associated 5 | documentation files (the "Software"), to deal in the 6 | Software without restriction, including without limitation 7 | the rights to use, copy, modify, merge, publish, distribute, 8 | sublicense, and/or sell copies of the Software, and to 9 | permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall 13 | be included in all copies or substantial portions of the 14 | Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 17 | KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 18 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 19 | PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS 20 | OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 21 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 22 | OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 23 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_netbsd_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build 386,netbsd 6 | 7 | package unix 8 | 9 | func Getpagesize() int { return 4096 } 10 | 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | func NsecToTimespec(nsec int64) (ts Timespec) { 14 | ts.Sec = int64(nsec / 1e9) 15 | ts.Nsec = int32(nsec % 1e9) 16 | return 17 | } 18 | 19 | func NsecToTimeval(nsec int64) (tv Timeval) { 20 | nsec += 999 // round up to microsecond 21 | tv.Usec = int32(nsec % 1e9 / 1e3) 22 | tv.Sec = int64(nsec / 1e9) 23 | return 24 | } 25 | 26 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 27 | k.Ident = uint32(fd) 28 | k.Filter = uint32(mode) 29 | k.Flags = uint32(flags) 30 | } 31 | 32 | func (iov *Iovec) SetLen(length int) { 33 | iov.Len = uint32(length) 34 | } 35 | 36 | func (msghdr *Msghdr) SetControllen(length int) { 37 | msghdr.Controllen = uint32(length) 38 | } 39 | 40 | func (cmsg *Cmsghdr) SetLen(length int) { 41 | cmsg.Len = uint32(length) 42 | } 43 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_netbsd_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build arm,netbsd 6 | 7 | package unix 8 | 9 | func Getpagesize() int { return 4096 } 10 | 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | func NsecToTimespec(nsec int64) (ts Timespec) { 14 | ts.Sec = int64(nsec / 1e9) 15 | ts.Nsec = int32(nsec % 1e9) 16 | return 17 | } 18 | 19 | func NsecToTimeval(nsec int64) (tv Timeval) { 20 | nsec += 999 // round up to microsecond 21 | tv.Usec = int32(nsec % 1e9 / 1e3) 22 | tv.Sec = int64(nsec / 1e9) 23 | return 24 | } 25 | 26 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 27 | k.Ident = uint32(fd) 28 | k.Filter = uint32(mode) 29 | k.Flags = uint32(flags) 30 | } 31 | 32 | func (iov *Iovec) SetLen(length int) { 33 | iov.Len = uint32(length) 34 | } 35 | 36 | func (msghdr *Msghdr) SetControllen(length int) { 37 | msghdr.Controllen = uint32(length) 38 | } 39 | 40 | func (cmsg *Cmsghdr) SetLen(length int) { 41 | cmsg.Len = uint32(length) 42 | } 43 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pretty/License: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright 2012 Keith Rarick 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_netbsd_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,netbsd 6 | 7 | package unix 8 | 9 | func Getpagesize() int { return 4096 } 10 | 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | func NsecToTimespec(nsec int64) (ts Timespec) { 14 | ts.Sec = int64(nsec / 1e9) 15 | ts.Nsec = int64(nsec % 1e9) 16 | return 17 | } 18 | 19 | func NsecToTimeval(nsec int64) (tv Timeval) { 20 | nsec += 999 // round up to microsecond 21 | tv.Usec = int32(nsec % 1e9 / 1e3) 22 | tv.Sec = int64(nsec / 1e9) 23 | return 24 | } 25 | 26 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 27 | k.Ident = uint64(fd) 28 | k.Filter = uint32(mode) 29 | k.Flags = uint32(flags) 30 | } 31 | 32 | func (iov *Iovec) SetLen(length int) { 33 | iov.Len = uint64(length) 34 | } 35 | 36 | func (msghdr *Msghdr) SetControllen(length int) { 37 | msghdr.Controllen = uint32(length) 38 | } 39 | 40 | func (cmsg *Cmsghdr) SetLen(length int) { 41 | cmsg.Len = uint32(length) 42 | } 43 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_openbsd_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build 386,openbsd 6 | 7 | package unix 8 | 9 | func Getpagesize() int { return 4096 } 10 | 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | func NsecToTimespec(nsec int64) (ts Timespec) { 14 | ts.Sec = int64(nsec / 1e9) 15 | ts.Nsec = int32(nsec % 1e9) 16 | return 17 | } 18 | 19 | func NsecToTimeval(nsec int64) (tv Timeval) { 20 | nsec += 999 // round up to microsecond 21 | tv.Usec = int32(nsec % 1e9 / 1e3) 22 | tv.Sec = int64(nsec / 1e9) 23 | return 24 | } 25 | 26 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 27 | k.Ident = uint32(fd) 28 | k.Filter = int16(mode) 29 | k.Flags = uint16(flags) 30 | } 31 | 32 | func (iov *Iovec) SetLen(length int) { 33 | iov.Len = uint32(length) 34 | } 35 | 36 | func (msghdr *Msghdr) SetControllen(length int) { 37 | msghdr.Controllen = uint32(length) 38 | } 39 | 40 | func (cmsg *Cmsghdr) SetLen(length int) { 41 | cmsg.Len = uint32(length) 42 | } 43 | -------------------------------------------------------------------------------- /vendor/github.com/fatih/color/LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013 Fatih Arslan 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /vendor/github.com/urfave/cli/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Jeremy Saenz & Contributors 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/codegangsta/cli/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Jeremy Saenz & Contributors 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pretty/zero.go: -------------------------------------------------------------------------------- 1 | package pretty 2 | 3 | import ( 4 | "reflect" 5 | ) 6 | 7 | func nonzero(v reflect.Value) bool { 8 | switch v.Kind() { 9 | case reflect.Bool: 10 | return v.Bool() 11 | case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: 12 | return v.Int() != 0 13 | case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: 14 | return v.Uint() != 0 15 | case reflect.Float32, reflect.Float64: 16 | return v.Float() != 0 17 | case reflect.Complex64, reflect.Complex128: 18 | return v.Complex() != complex(0, 0) 19 | case reflect.String: 20 | return v.String() != "" 21 | case reflect.Struct: 22 | for i := 0; i < v.NumField(); i++ { 23 | if nonzero(getField(v, i)) { 24 | return true 25 | } 26 | } 27 | return false 28 | case reflect.Array: 29 | for i := 0; i < v.Len(); i++ { 30 | if nonzero(v.Index(i)) { 31 | return true 32 | } 33 | } 34 | return false 35 | case reflect.Map, reflect.Interface, reflect.Slice, reflect.Ptr, reflect.Chan, reflect.Func: 36 | return !v.IsNil() 37 | case reflect.UnsafePointer: 38 | return v.Pointer() != 0 39 | } 40 | return true 41 | } 42 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-colorable/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Yasuhiro Matsumoto 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/gccgo_c.c: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build gccgo 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #define _STRINGIFY2_(x) #x 12 | #define _STRINGIFY_(x) _STRINGIFY2_(x) 13 | #define GOSYM_PREFIX _STRINGIFY_(__USER_LABEL_PREFIX__) 14 | 15 | // Call syscall from C code because the gccgo support for calling from 16 | // Go to C does not support varargs functions. 17 | 18 | struct ret { 19 | uintptr_t r; 20 | uintptr_t err; 21 | }; 22 | 23 | struct ret 24 | gccgoRealSyscall(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9) 25 | { 26 | struct ret r; 27 | 28 | errno = 0; 29 | r.r = syscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9); 30 | r.err = errno; 31 | return r; 32 | } 33 | 34 | // Define the use function in C so that it is not inlined. 35 | 36 | extern void use(void *) __asm__ (GOSYM_PREFIX GOPKGPATH ".use") __attribute__((noinline)); 37 | 38 | void 39 | use(void *p __attribute__ ((unused))) 40 | { 41 | } 42 | -------------------------------------------------------------------------------- /vendor/github.com/BurntSushi/toml/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package toml provides facilities for decoding and encoding TOML configuration 3 | files via reflection. There is also support for delaying decoding with 4 | the Primitive type, and querying the set of keys in a TOML document with the 5 | MetaData type. 6 | 7 | The specification implemented: https://github.com/mojombo/toml 8 | 9 | The sub-command github.com/BurntSushi/toml/cmd/tomlv can be used to verify 10 | whether a file is a valid TOML document. It can also be used to print the 11 | type of each key in a TOML document. 12 | 13 | Testing 14 | 15 | There are two important types of tests used for this package. The first is 16 | contained inside '*_test.go' files and uses the standard Go unit testing 17 | framework. These tests are primarily devoted to holistically testing the 18 | decoder and encoder. 19 | 20 | The second type of testing is used to verify the implementation's adherence 21 | to the TOML specification. These tests have been factored into their own 22 | project: https://github.com/BurntSushi/toml-test 23 | 24 | The reason the tests are in a separate project is so that they can be used by 25 | any implementation of TOML. Namely, it is language agnostic. 26 | */ 27 | package toml 28 | -------------------------------------------------------------------------------- /vendor/github.com/dustin/go-humanize/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2005-2008 Dustin Sallings 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | 21 | 22 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/sockcmsg_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Socket control messages 6 | 7 | package unix 8 | 9 | import "unsafe" 10 | 11 | // UnixCredentials encodes credentials into a socket control message 12 | // for sending to another process. This can be used for 13 | // authentication. 14 | func UnixCredentials(ucred *Ucred) []byte { 15 | b := make([]byte, CmsgSpace(SizeofUcred)) 16 | h := (*Cmsghdr)(unsafe.Pointer(&b[0])) 17 | h.Level = SOL_SOCKET 18 | h.Type = SCM_CREDENTIALS 19 | h.SetLen(CmsgLen(SizeofUcred)) 20 | *((*Ucred)(cmsgData(h))) = *ucred 21 | return b 22 | } 23 | 24 | // ParseUnixCredentials decodes a socket control message that contains 25 | // credentials in a Ucred structure. To receive such a message, the 26 | // SO_PASSCRED option must be enabled on the socket. 27 | func ParseUnixCredentials(m *SocketControlMessage) (*Ucred, error) { 28 | if m.Header.Level != SOL_SOCKET { 29 | return nil, EINVAL 30 | } 31 | if m.Header.Type != SCM_CREDENTIALS { 32 | return nil, EINVAL 33 | } 34 | ucred := *(*Ucred)(unsafe.Pointer(&m.Data[0])) 35 | return &ucred, nil 36 | } 37 | -------------------------------------------------------------------------------- /json/tags.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package json 6 | 7 | import ( 8 | "strings" 9 | ) 10 | 11 | // tagOptions is the string following a comma in a struct field's "json" 12 | // tag, or the empty string. It does not include the leading comma. 13 | type tagOptions string 14 | 15 | // parseTag splits a struct field's json tag into its name and 16 | // comma-separated options. 17 | func parseTag(tag string) (string, tagOptions) { 18 | if idx := strings.Index(tag, ","); idx != -1 { 19 | return tag[:idx], tagOptions(tag[idx+1:]) 20 | } 21 | return tag, tagOptions("") 22 | } 23 | 24 | // Contains reports whether a comma-separated list of options 25 | // contains a particular substr flag. substr must be surrounded by a 26 | // string boundary or commas. 27 | func (o tagOptions) Contains(optionName string) bool { 28 | if len(o) == 0 { 29 | return false 30 | } 31 | s := string(o) 32 | for s != "" { 33 | var next string 34 | i := strings.Index(s, ",") 35 | if i >= 0 { 36 | s, next = s[:i], s[i+1:] 37 | } 38 | if s == optionName { 39 | return true 40 | } 41 | s = next 42 | } 43 | return false 44 | } 45 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-colorable/noncolorable.go: -------------------------------------------------------------------------------- 1 | package colorable 2 | 3 | import ( 4 | "bytes" 5 | "fmt" 6 | "io" 7 | ) 8 | 9 | type NonColorable struct { 10 | out io.Writer 11 | lastbuf bytes.Buffer 12 | } 13 | 14 | func NewNonColorable(w io.Writer) io.Writer { 15 | return &NonColorable{out: w} 16 | } 17 | 18 | func (w *NonColorable) Write(data []byte) (n int, err error) { 19 | er := bytes.NewBuffer(data) 20 | loop: 21 | for { 22 | c1, _, err := er.ReadRune() 23 | if err != nil { 24 | break loop 25 | } 26 | if c1 != 0x1b { 27 | fmt.Fprint(w.out, string(c1)) 28 | continue 29 | } 30 | c2, _, err := er.ReadRune() 31 | if err != nil { 32 | w.lastbuf.WriteRune(c1) 33 | break loop 34 | } 35 | if c2 != 0x5b { 36 | w.lastbuf.WriteRune(c1) 37 | w.lastbuf.WriteRune(c2) 38 | continue 39 | } 40 | 41 | var buf bytes.Buffer 42 | for { 43 | c, _, err := er.ReadRune() 44 | if err != nil { 45 | w.lastbuf.WriteRune(c1) 46 | w.lastbuf.WriteRune(c2) 47 | w.lastbuf.Write(buf.Bytes()) 48 | break loop 49 | } 50 | if ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') || c == '@' { 51 | break 52 | } 53 | buf.Write([]byte(string(c))) 54 | } 55 | } 56 | return len(data) - w.lastbuf.Len(), nil 57 | } 58 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/ioctl_bsd.go: -------------------------------------------------------------------------------- 1 | // +build darwin dragonfly freebsd netbsd openbsd 2 | 3 | package pty 4 | 5 | // from 6 | const ( 7 | _IOC_VOID uintptr = 0x20000000 8 | _IOC_OUT uintptr = 0x40000000 9 | _IOC_IN uintptr = 0x80000000 10 | _IOC_IN_OUT uintptr = _IOC_OUT | _IOC_IN 11 | _IOC_DIRMASK = _IOC_VOID | _IOC_OUT | _IOC_IN 12 | 13 | _IOC_PARAM_SHIFT = 13 14 | _IOC_PARAM_MASK = (1 << _IOC_PARAM_SHIFT) - 1 15 | ) 16 | 17 | func _IOC_PARM_LEN(ioctl uintptr) uintptr { 18 | return (ioctl >> 16) & _IOC_PARAM_MASK 19 | } 20 | 21 | func _IOC(inout uintptr, group byte, ioctl_num uintptr, param_len uintptr) uintptr { 22 | return inout | (param_len&_IOC_PARAM_MASK)<<16 | uintptr(group)<<8 | ioctl_num 23 | } 24 | 25 | func _IO(group byte, ioctl_num uintptr) uintptr { 26 | return _IOC(_IOC_VOID, group, ioctl_num, 0) 27 | } 28 | 29 | func _IOR(group byte, ioctl_num uintptr, param_len uintptr) uintptr { 30 | return _IOC(_IOC_OUT, group, ioctl_num, param_len) 31 | } 32 | 33 | func _IOW(group byte, ioctl_num uintptr, param_len uintptr) uintptr { 34 | return _IOC(_IOC_IN, group, ioctl_num, param_len) 35 | } 36 | 37 | func _IOWR(group byte, ioctl_num uintptr, param_len uintptr) uintptr { 38 | return _IOC(_IOC_IN_OUT, group, ioctl_num, param_len) 39 | } 40 | -------------------------------------------------------------------------------- /vendor/github.com/urfave/cli/category.go: -------------------------------------------------------------------------------- 1 | package cli 2 | 3 | // CommandCategories is a slice of *CommandCategory. 4 | type CommandCategories []*CommandCategory 5 | 6 | // CommandCategory is a category containing commands. 7 | type CommandCategory struct { 8 | Name string 9 | Commands Commands 10 | } 11 | 12 | func (c CommandCategories) Less(i, j int) bool { 13 | return c[i].Name < c[j].Name 14 | } 15 | 16 | func (c CommandCategories) Len() int { 17 | return len(c) 18 | } 19 | 20 | func (c CommandCategories) Swap(i, j int) { 21 | c[i], c[j] = c[j], c[i] 22 | } 23 | 24 | // AddCommand adds a command to a category. 25 | func (c CommandCategories) AddCommand(category string, command Command) CommandCategories { 26 | for _, commandCategory := range c { 27 | if commandCategory.Name == category { 28 | commandCategory.Commands = append(commandCategory.Commands, command) 29 | return c 30 | } 31 | } 32 | return append(c, &CommandCategory{Name: category, Commands: []Command{command}}) 33 | } 34 | 35 | // VisibleCommands returns a slice of the Commands with Hidden=false 36 | func (c *CommandCategory) VisibleCommands() []Command { 37 | ret := []Command{} 38 | for _, command := range c.Commands { 39 | if !command.Hidden { 40 | ret = append(ret, command) 41 | } 42 | } 43 | return ret 44 | } 45 | -------------------------------------------------------------------------------- /vendor/github.com/codegangsta/cli/category.go: -------------------------------------------------------------------------------- 1 | package cli 2 | 3 | // CommandCategories is a slice of *CommandCategory. 4 | type CommandCategories []*CommandCategory 5 | 6 | // CommandCategory is a category containing commands. 7 | type CommandCategory struct { 8 | Name string 9 | Commands Commands 10 | } 11 | 12 | func (c CommandCategories) Less(i, j int) bool { 13 | return c[i].Name < c[j].Name 14 | } 15 | 16 | func (c CommandCategories) Len() int { 17 | return len(c) 18 | } 19 | 20 | func (c CommandCategories) Swap(i, j int) { 21 | c[i], c[j] = c[j], c[i] 22 | } 23 | 24 | // AddCommand adds a command to a category. 25 | func (c CommandCategories) AddCommand(category string, command Command) CommandCategories { 26 | for _, commandCategory := range c { 27 | if commandCategory.Name == category { 28 | commandCategory.Commands = append(commandCategory.Commands, command) 29 | return c 30 | } 31 | } 32 | return append(c, &CommandCategory{Name: category, Commands: []Command{command}}) 33 | } 34 | 35 | // VisibleCommands returns a slice of the Commands with Hidden=false 36 | func (c *CommandCategory) VisibleCommands() []Command { 37 | ret := []Command{} 38 | for _, command := range c.Commands { 39 | if !command.Hidden { 40 | ret = append(ret, command) 41 | } 42 | } 43 | return ret 44 | } 45 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/pty_darwin.go: -------------------------------------------------------------------------------- 1 | package pty 2 | 3 | import ( 4 | "errors" 5 | "os" 6 | "syscall" 7 | "unsafe" 8 | ) 9 | 10 | func open() (pty, tty *os.File, err error) { 11 | p, err := os.OpenFile("/dev/ptmx", os.O_RDWR, 0) 12 | if err != nil { 13 | return nil, nil, err 14 | } 15 | 16 | sname, err := ptsname(p) 17 | if err != nil { 18 | return nil, nil, err 19 | } 20 | 21 | err = grantpt(p) 22 | if err != nil { 23 | return nil, nil, err 24 | } 25 | 26 | err = unlockpt(p) 27 | if err != nil { 28 | return nil, nil, err 29 | } 30 | 31 | t, err := os.OpenFile(sname, os.O_RDWR, 0) 32 | if err != nil { 33 | return nil, nil, err 34 | } 35 | return p, t, nil 36 | } 37 | 38 | func ptsname(f *os.File) (string, error) { 39 | n := make([]byte, _IOC_PARM_LEN(syscall.TIOCPTYGNAME)) 40 | 41 | err := ioctl(f.Fd(), syscall.TIOCPTYGNAME, uintptr(unsafe.Pointer(&n[0]))) 42 | if err != nil { 43 | return "", err 44 | } 45 | 46 | for i, c := range n { 47 | if c == 0 { 48 | return string(n[:i]), nil 49 | } 50 | } 51 | return "", errors.New("TIOCPTYGNAME string not NUL-terminated") 52 | } 53 | 54 | func grantpt(f *os.File) error { 55 | return ioctl(f.Fd(), syscall.TIOCPTYGRANT, 0) 56 | } 57 | 58 | func unlockpt(f *os.File) error { 59 | return ioctl(f.Fd(), syscall.TIOCPTYUNLK, 0) 60 | } 61 | -------------------------------------------------------------------------------- /vendor/github.com/op/go-logging/backend.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013, Örjan Persson. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package logging 6 | 7 | // defaultBackend is the backend used for all logging calls. 8 | var defaultBackend LeveledBackend 9 | 10 | // Backend is the interface which a log backend need to implement to be able to 11 | // be used as a logging backend. 12 | type Backend interface { 13 | Log(Level, int, *Record) error 14 | } 15 | 16 | // SetBackend replaces the backend currently set with the given new logging 17 | // backend. 18 | func SetBackend(backends ...Backend) LeveledBackend { 19 | var backend Backend 20 | if len(backends) == 1 { 21 | backend = backends[0] 22 | } else { 23 | backend = MultiLogger(backends...) 24 | } 25 | 26 | defaultBackend = AddModuleLevel(backend) 27 | return defaultBackend 28 | } 29 | 30 | // SetLevel sets the logging level for the specified module. The module 31 | // corresponds to the string specified in GetLogger. 32 | func SetLevel(level Level, module string) { 33 | defaultBackend.SetLevel(level, module) 34 | } 35 | 36 | // GetLevel returns the logging level for the specified module. 37 | func GetLevel(module string) Level { 38 | return defaultBackend.GetLevel(module) 39 | } 40 | -------------------------------------------------------------------------------- /vendor/github.com/BurntSushi/toml/cmd/tomlv/main.go: -------------------------------------------------------------------------------- 1 | // Command tomlv validates TOML documents and prints each key's type. 2 | package main 3 | 4 | import ( 5 | "flag" 6 | "fmt" 7 | "log" 8 | "os" 9 | "path" 10 | "strings" 11 | "text/tabwriter" 12 | 13 | "github.com/BurntSushi/toml" 14 | ) 15 | 16 | var ( 17 | flagTypes = false 18 | ) 19 | 20 | func init() { 21 | log.SetFlags(0) 22 | 23 | flag.BoolVar(&flagTypes, "types", flagTypes, 24 | "When set, the types of every defined key will be shown.") 25 | 26 | flag.Usage = usage 27 | flag.Parse() 28 | } 29 | 30 | func usage() { 31 | log.Printf("Usage: %s toml-file [ toml-file ... ]\n", 32 | path.Base(os.Args[0])) 33 | flag.PrintDefaults() 34 | 35 | os.Exit(1) 36 | } 37 | 38 | func main() { 39 | if flag.NArg() < 1 { 40 | flag.Usage() 41 | } 42 | for _, f := range flag.Args() { 43 | var tmp interface{} 44 | md, err := toml.DecodeFile(f, &tmp) 45 | if err != nil { 46 | log.Fatalf("Error in '%s': %s", f, err) 47 | } 48 | if flagTypes { 49 | printTypes(md) 50 | } 51 | } 52 | } 53 | 54 | func printTypes(md toml.MetaData) { 55 | tabw := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0) 56 | for _, key := range md.Keys() { 57 | fmt.Fprintf(tabw, "%s%s\t%s\n", 58 | strings.Repeat(" ", len(key)-1), key, md.Type(key...)) 59 | } 60 | tabw.Flush() 61 | } 62 | -------------------------------------------------------------------------------- /cmd/template.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "github.com/dutchcoders/elastico/json" 5 | "fmt" 6 | "regexp" 7 | "text/template" 8 | 9 | humanize "github.com/dustin/go-humanize" 10 | "github.com/fatih/color" 11 | "github.com/kr/pretty" 12 | ) 13 | 14 | var ( 15 | funcMap = template.FuncMap{ 16 | "pad": Pad, 17 | "red": color.RedString, 18 | "green": color.GreenString, 19 | "yellow": color.YellowString, 20 | "blue": color.BlueString, 21 | "trim": func(v string) string { 22 | re := regexp.MustCompile("\\s+") 23 | return re.ReplaceAllLiteralString(v, " ") 24 | }, 25 | "pretty": pretty.Print, 26 | "json": func(v interface{}) (string, error) { 27 | b, err := json.MarshalIndent(v, "", " ") 28 | return string(b), err 29 | }, 30 | "time": func(v interface{}) (string, error) { 31 | return fmt.Sprintf("%d", (uint64(v.(float64)))/1000), nil 32 | // return humanize.Time(uint64(v.(float64))), nil 33 | }, 34 | "bytes": func(v interface{}) (string, error) { 35 | return humanize.Bytes(uint64(v.(float64))), nil 36 | }, 37 | "has": func(v interface{}, key string) (bool, error) { 38 | if m, ok := v.(json.M); !ok { 39 | return false, nil 40 | } else { 41 | _, match := m[key] 42 | return match, nil 43 | } 44 | }, 45 | } 46 | ) 47 | 48 | func Pad(v string, count int) string { 49 | return v // + strconv.Itoa(arg) 50 | } 51 | -------------------------------------------------------------------------------- /vendor/github.com/urfave/cli/funcs.go: -------------------------------------------------------------------------------- 1 | package cli 2 | 3 | // BashCompleteFunc is an action to execute when the bash-completion flag is set 4 | type BashCompleteFunc func(*Context) 5 | 6 | // BeforeFunc is an action to execute before any subcommands are run, but after 7 | // the context is ready if a non-nil error is returned, no subcommands are run 8 | type BeforeFunc func(*Context) error 9 | 10 | // AfterFunc is an action to execute after any subcommands are run, but after the 11 | // subcommand has finished it is run even if Action() panics 12 | type AfterFunc func(*Context) error 13 | 14 | // ActionFunc is the action to execute when no subcommands are specified 15 | type ActionFunc func(*Context) error 16 | 17 | // CommandNotFoundFunc is executed if the proper command cannot be found 18 | type CommandNotFoundFunc func(*Context, string) 19 | 20 | // OnUsageErrorFunc is executed if an usage error occurs. This is useful for displaying 21 | // customized usage error messages. This function is able to replace the 22 | // original error messages. If this function is not set, the "Incorrect usage" 23 | // is displayed and the execution is interrupted. 24 | type OnUsageErrorFunc func(context *Context, err error, isSubcommand bool) error 25 | 26 | // FlagStringFunc is used by the help generation to display a flag, which is 27 | // expected to be a single line. 28 | type FlagStringFunc func(Flag) string 29 | -------------------------------------------------------------------------------- /vendor/github.com/codegangsta/cli/funcs.go: -------------------------------------------------------------------------------- 1 | package cli 2 | 3 | // BashCompleteFunc is an action to execute when the bash-completion flag is set 4 | type BashCompleteFunc func(*Context) 5 | 6 | // BeforeFunc is an action to execute before any subcommands are run, but after 7 | // the context is ready if a non-nil error is returned, no subcommands are run 8 | type BeforeFunc func(*Context) error 9 | 10 | // AfterFunc is an action to execute after any subcommands are run, but after the 11 | // subcommand has finished it is run even if Action() panics 12 | type AfterFunc func(*Context) error 13 | 14 | // ActionFunc is the action to execute when no subcommands are specified 15 | type ActionFunc func(*Context) error 16 | 17 | // CommandNotFoundFunc is executed if the proper command cannot be found 18 | type CommandNotFoundFunc func(*Context, string) 19 | 20 | // OnUsageErrorFunc is executed if an usage error occurs. This is useful for displaying 21 | // customized usage error messages. This function is able to replace the 22 | // original error messages. If this function is not set, the "Incorrect usage" 23 | // is displayed and the execution is interrupted. 24 | type OnUsageErrorFunc func(context *Context, err error, isSubcommand bool) error 25 | 26 | // FlagStringFunc is used by the help generation to display a flag, which is 27 | // expected to be a single line. 28 | type FlagStringFunc func(Flag) string 29 | -------------------------------------------------------------------------------- /vendor/gopkg.in/check.v1/LICENSE: -------------------------------------------------------------------------------- 1 | Gocheck - A rich testing framework for Go 2 | 3 | Copyright (c) 2010-2013 Gustavo Niemeyer 4 | 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | 1. Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | 2. Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | -------------------------------------------------------------------------------- /vendor/github.com/cheggaaa/pb/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012-2015, Sergey Cherepanov 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 5 | 6 | * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 7 | 8 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 9 | 10 | * Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 11 | 12 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /vendor/gopkg.in/cheggaaa/pb.v1/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012-2015, Sergey Cherepanov 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 5 | 6 | * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 7 | 8 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 9 | 10 | * Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 11 | 12 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /vendor/github.com/kr/text/mc/mc.go: -------------------------------------------------------------------------------- 1 | // Command mc prints in multiple columns. 2 | // 3 | // Usage: mc [-] [-N] [file...] 4 | // 5 | // Mc splits the input into as many columns as will fit in N 6 | // print positions. If the output is a tty, the default N is 7 | // the number of characters in a terminal line; otherwise the 8 | // default N is 80. Under option - each input line ending in 9 | // a colon ':' is printed separately. 10 | package main 11 | 12 | import ( 13 | "github.com/kr/pty" 14 | "github.com/kr/text/colwriter" 15 | "io" 16 | "log" 17 | "os" 18 | "strconv" 19 | ) 20 | 21 | func main() { 22 | var width int 23 | var flag uint 24 | args := os.Args[1:] 25 | for len(args) > 0 && len(args[0]) > 0 && args[0][0] == '-' { 26 | if len(args[0]) > 1 { 27 | width, _ = strconv.Atoi(args[0][1:]) 28 | } else { 29 | flag |= colwriter.BreakOnColon 30 | } 31 | args = args[1:] 32 | } 33 | if width < 1 { 34 | _, width, _ = pty.Getsize(os.Stdout) 35 | } 36 | if width < 1 { 37 | width = 80 38 | } 39 | 40 | w := colwriter.NewWriter(os.Stdout, width, flag) 41 | if len(args) > 0 { 42 | for _, s := range args { 43 | if f, err := os.Open(s); err == nil { 44 | copyin(w, f) 45 | f.Close() 46 | } else { 47 | log.Println(err) 48 | } 49 | } 50 | } else { 51 | copyin(w, os.Stdin) 52 | } 53 | } 54 | 55 | func copyin(w *colwriter.Writer, r io.Reader) { 56 | if _, err := io.Copy(w, r); err != nil { 57 | log.Println(err) 58 | } 59 | if err := w.Flush(); err != nil { 60 | log.Println(err) 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /vendor/github.com/op/go-logging/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013 Örjan Persson. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/gopkg.in/cheggaaa/pb.v1/pool.go: -------------------------------------------------------------------------------- 1 | // +build linux darwin freebsd netbsd openbsd solaris dragonfly windows 2 | 3 | package pb 4 | 5 | import ( 6 | "sync" 7 | "time" 8 | ) 9 | 10 | // Create and start new pool with given bars 11 | // You need call pool.Stop() after work 12 | func StartPool(pbs ...*ProgressBar) (pool *Pool, err error) { 13 | pool = new(Pool) 14 | if err = pool.start(); err != nil { 15 | return 16 | } 17 | pool.add(pbs...) 18 | return 19 | } 20 | 21 | type Pool struct { 22 | RefreshRate time.Duration 23 | bars []*ProgressBar 24 | quit chan int 25 | finishOnce sync.Once 26 | } 27 | 28 | func (p *Pool) add(pbs ...*ProgressBar) { 29 | for _, bar := range pbs { 30 | bar.ManualUpdate = true 31 | bar.NotPrint = true 32 | bar.Start() 33 | p.bars = append(p.bars, bar) 34 | } 35 | } 36 | 37 | func (p *Pool) start() (err error) { 38 | p.RefreshRate = DefaultRefreshRate 39 | quit, err := lockEcho() 40 | if err != nil { 41 | return 42 | } 43 | p.quit = make(chan int) 44 | go p.writer(quit) 45 | return 46 | } 47 | 48 | func (p *Pool) writer(finish chan int) { 49 | var first = true 50 | for { 51 | select { 52 | case <-time.After(p.RefreshRate): 53 | if p.print(first) { 54 | p.print(false) 55 | finish <- 1 56 | return 57 | } 58 | first = false 59 | case <-p.quit: 60 | finish <- 1 61 | return 62 | } 63 | } 64 | } 65 | 66 | // Restore terminal state and close pool 67 | func (p *Pool) Stop() error { 68 | // Wait until one final refresh has passed. 69 | time.Sleep(p.RefreshRate) 70 | 71 | p.finishOnce.Do(func() { 72 | close(p.quit) 73 | }) 74 | return unlockEcho() 75 | } 76 | -------------------------------------------------------------------------------- /vendor/github.com/cheggaaa/pb/pool.go: -------------------------------------------------------------------------------- 1 | // +build linux darwin freebsd netbsd openbsd solaris dragonfly windows 2 | 3 | package pb 4 | 5 | import ( 6 | "sync" 7 | "time" 8 | ) 9 | 10 | // Create and start new pool with given bars 11 | // You need call pool.Stop() after work 12 | func StartPool(pbs ...*ProgressBar) (pool *Pool, err error) { 13 | pool = new(Pool) 14 | if err = pool.start(); err != nil { 15 | return 16 | } 17 | pool.Add(pbs...) 18 | return 19 | } 20 | 21 | type Pool struct { 22 | RefreshRate time.Duration 23 | bars []*ProgressBar 24 | quit chan int 25 | finishOnce sync.Once 26 | } 27 | 28 | // Add progress bars. 29 | func (p *Pool) Add(pbs ...*ProgressBar) { 30 | for _, bar := range pbs { 31 | bar.ManualUpdate = true 32 | bar.NotPrint = true 33 | bar.Start() 34 | p.bars = append(p.bars, bar) 35 | } 36 | } 37 | 38 | func (p *Pool) start() (err error) { 39 | p.RefreshRate = DefaultRefreshRate 40 | quit, err := lockEcho() 41 | if err != nil { 42 | return 43 | } 44 | p.quit = make(chan int) 45 | go p.writer(quit) 46 | return 47 | } 48 | 49 | func (p *Pool) writer(finish chan int) { 50 | var first = true 51 | for { 52 | select { 53 | case <-time.After(p.RefreshRate): 54 | if p.print(first) { 55 | p.print(false) 56 | finish <- 1 57 | return 58 | } 59 | first = false 60 | case <-p.quit: 61 | finish <- 1 62 | return 63 | } 64 | } 65 | } 66 | 67 | // Restore terminal state and close pool 68 | func (p *Pool) Stop() error { 69 | // Wait until one final refresh has passed. 70 | time.Sleep(p.RefreshRate) 71 | 72 | p.finishOnce.Do(func() { 73 | close(p.quit) 74 | }) 75 | return unlockEcho() 76 | } 77 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_dragonfly_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,dragonfly 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = nsec / 1e9 20 | ts.Nsec = nsec % 1e9 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = nsec % 1e9 / 1e3 27 | tv.Sec = int64(nsec / 1e9) 28 | return 29 | } 30 | 31 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 32 | k.Ident = uint64(fd) 33 | k.Filter = int16(mode) 34 | k.Flags = uint16(flags) 35 | } 36 | 37 | func (iov *Iovec) SetLen(length int) { 38 | iov.Len = uint64(length) 39 | } 40 | 41 | func (msghdr *Msghdr) SetControllen(length int) { 42 | msghdr.Controllen = uint32(length) 43 | } 44 | 45 | func (cmsg *Cmsghdr) SetLen(length int) { 46 | cmsg.Len = uint32(length) 47 | } 48 | 49 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 50 | var writtenOut uint64 = 0 51 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) 52 | 53 | written = int(writtenOut) 54 | 55 | if e1 != 0 { 56 | err = e1 57 | } 58 | return 59 | } 60 | 61 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 62 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_freebsd_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,freebsd 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = nsec / 1e9 20 | ts.Nsec = nsec % 1e9 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = nsec % 1e9 / 1e3 27 | tv.Sec = int64(nsec / 1e9) 28 | return 29 | } 30 | 31 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 32 | k.Ident = uint64(fd) 33 | k.Filter = int16(mode) 34 | k.Flags = uint16(flags) 35 | } 36 | 37 | func (iov *Iovec) SetLen(length int) { 38 | iov.Len = uint64(length) 39 | } 40 | 41 | func (msghdr *Msghdr) SetControllen(length int) { 42 | msghdr.Controllen = uint32(length) 43 | } 44 | 45 | func (cmsg *Cmsghdr) SetLen(length int) { 46 | cmsg.Len = uint32(length) 47 | } 48 | 49 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 50 | var writtenOut uint64 = 0 51 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) 52 | 53 | written = int(writtenOut) 54 | 55 | if e1 != 0 { 56 | err = e1 57 | } 58 | return 59 | } 60 | 61 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 62 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_freebsd_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build arm,freebsd 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return ts.Sec*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = nsec / 1e9 20 | ts.Nsec = int32(nsec % 1e9) 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = int32(nsec % 1e9 / 1e3) 27 | tv.Sec = nsec / 1e9 28 | return 29 | } 30 | 31 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 32 | k.Ident = uint32(fd) 33 | k.Filter = int16(mode) 34 | k.Flags = uint16(flags) 35 | } 36 | 37 | func (iov *Iovec) SetLen(length int) { 38 | iov.Len = uint32(length) 39 | } 40 | 41 | func (msghdr *Msghdr) SetControllen(length int) { 42 | msghdr.Controllen = uint32(length) 43 | } 44 | 45 | func (cmsg *Cmsghdr) SetLen(length int) { 46 | cmsg.Len = uint32(length) 47 | } 48 | 49 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 50 | var writtenOut uint64 = 0 51 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) 52 | 53 | written = int(writtenOut) 54 | 55 | if e1 != 0 { 56 | err = e1 57 | } 58 | return 59 | } 60 | 61 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 62 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/pty_freebsd.go: -------------------------------------------------------------------------------- 1 | package pty 2 | 3 | import ( 4 | "errors" 5 | "os" 6 | "syscall" 7 | "unsafe" 8 | ) 9 | 10 | func posix_openpt(oflag int) (fd int, err error) { 11 | r0, _, e1 := syscall.Syscall(syscall.SYS_POSIX_OPENPT, uintptr(oflag), 0, 0) 12 | fd = int(r0) 13 | if e1 != 0 { 14 | err = e1 15 | } 16 | return 17 | } 18 | 19 | func open() (pty, tty *os.File, err error) { 20 | fd, err := posix_openpt(syscall.O_RDWR | syscall.O_CLOEXEC) 21 | if err != nil { 22 | return nil, nil, err 23 | } 24 | 25 | p := os.NewFile(uintptr(fd), "/dev/pts") 26 | sname, err := ptsname(p) 27 | if err != nil { 28 | return nil, nil, err 29 | } 30 | 31 | t, err := os.OpenFile("/dev/"+sname, os.O_RDWR, 0) 32 | if err != nil { 33 | return nil, nil, err 34 | } 35 | return p, t, nil 36 | } 37 | 38 | func isptmaster(fd uintptr) (bool, error) { 39 | err := ioctl(fd, syscall.TIOCPTMASTER, 0) 40 | return err == nil, err 41 | } 42 | 43 | var ( 44 | emptyFiodgnameArg fiodgnameArg 45 | ioctl_FIODGNAME = _IOW('f', 120, unsafe.Sizeof(emptyFiodgnameArg)) 46 | ) 47 | 48 | func ptsname(f *os.File) (string, error) { 49 | master, err := isptmaster(f.Fd()) 50 | if err != nil { 51 | return "", err 52 | } 53 | if !master { 54 | return "", syscall.EINVAL 55 | } 56 | 57 | const n = _C_SPECNAMELEN + 1 58 | var ( 59 | buf = make([]byte, n) 60 | arg = fiodgnameArg{Len: n, Buf: (*byte)(unsafe.Pointer(&buf[0]))} 61 | ) 62 | err = ioctl(f.Fd(), ioctl_FIODGNAME, uintptr(unsafe.Pointer(&arg))) 63 | if err != nil { 64 | return "", err 65 | } 66 | 67 | for i, c := range buf { 68 | if c == 0 { 69 | return string(buf[:i]), nil 70 | } 71 | } 72 | return "", errors.New("FIODGNAME string not NUL-terminated") 73 | } 74 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_freebsd_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build 386,freebsd 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = int32(nsec / 1e9) 20 | ts.Nsec = int32(nsec % 1e9) 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = int32(nsec % 1e9 / 1e3) 27 | tv.Sec = int32(nsec / 1e9) 28 | return 29 | } 30 | 31 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 32 | k.Ident = uint32(fd) 33 | k.Filter = int16(mode) 34 | k.Flags = uint16(flags) 35 | } 36 | 37 | func (iov *Iovec) SetLen(length int) { 38 | iov.Len = uint32(length) 39 | } 40 | 41 | func (msghdr *Msghdr) SetControllen(length int) { 42 | msghdr.Controllen = uint32(length) 43 | } 44 | 45 | func (cmsg *Cmsghdr) SetLen(length int) { 46 | cmsg.Len = uint32(length) 47 | } 48 | 49 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 50 | var writtenOut uint64 = 0 51 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) 52 | 53 | written = int(writtenOut) 54 | 55 | if e1 != 0 { 56 | err = e1 57 | } 58 | return 59 | } 60 | 61 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 62 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/gccgo.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build gccgo 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | // We can't use the gc-syntax .s files for gccgo. On the plus side 12 | // much of the functionality can be written directly in Go. 13 | 14 | //extern gccgoRealSyscall 15 | func realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r, errno uintptr) 16 | 17 | func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) { 18 | syscall.Entersyscall() 19 | r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 20 | syscall.Exitsyscall() 21 | return r, 0, syscall.Errno(errno) 22 | } 23 | 24 | func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) { 25 | syscall.Entersyscall() 26 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0) 27 | syscall.Exitsyscall() 28 | return r, 0, syscall.Errno(errno) 29 | } 30 | 31 | func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) { 32 | syscall.Entersyscall() 33 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9) 34 | syscall.Exitsyscall() 35 | return r, 0, syscall.Errno(errno) 36 | } 37 | 38 | func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) { 39 | r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 40 | return r, 0, syscall.Errno(errno) 41 | } 42 | 43 | func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) { 44 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0) 45 | return r, 0, syscall.Errno(errno) 46 | } 47 | -------------------------------------------------------------------------------- /vendor/github.com/op/go-logging/examples/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "os" 5 | 6 | "github.com/op/go-logging" 7 | ) 8 | 9 | var log = logging.MustGetLogger("example") 10 | 11 | // Example format string. Everything except the message has a custom color 12 | // which is dependent on the log level. Many fields have a custom output 13 | // formatting too, eg. the time returns the hour down to the milli second. 14 | var format = logging.MustStringFormatter( 15 | `%{color}%{time:15:04:05.000} %{shortfunc} ▶ %{level:.4s} %{id:03x}%{color:reset} %{message}`, 16 | ) 17 | 18 | // Password is just an example type implementing the Redactor interface. Any 19 | // time this is logged, the Redacted() function will be called. 20 | type Password string 21 | 22 | func (p Password) Redacted() interface{} { 23 | return logging.Redact(string(p)) 24 | } 25 | 26 | func main() { 27 | // For demo purposes, create two backend for os.Stderr. 28 | backend1 := logging.NewLogBackend(os.Stderr, "", 0) 29 | backend2 := logging.NewLogBackend(os.Stderr, "", 0) 30 | 31 | // For messages written to backend2 we want to add some additional 32 | // information to the output, including the used log level and the name of 33 | // the function. 34 | backend2Formatter := logging.NewBackendFormatter(backend2, format) 35 | 36 | // Only errors and more severe messages should be sent to backend1 37 | backend1Leveled := logging.AddModuleLevel(backend1) 38 | backend1Leveled.SetLevel(logging.ERROR, "") 39 | 40 | // Set the backends to be used. 41 | logging.SetBackend(backend1Leveled, backend2Formatter) 42 | 43 | log.Debugf("debug %s", Password("secret")) 44 | log.Info("info") 45 | log.Notice("notice") 46 | log.Warning("warning") 47 | log.Error("err") 48 | log.Critical("crit") 49 | } 50 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/pty_dragonfly.go: -------------------------------------------------------------------------------- 1 | package pty 2 | 3 | import ( 4 | "errors" 5 | "os" 6 | "strings" 7 | "syscall" 8 | "unsafe" 9 | ) 10 | 11 | // same code as pty_darwin.go 12 | func open() (pty, tty *os.File, err error) { 13 | p, err := os.OpenFile("/dev/ptmx", os.O_RDWR, 0) 14 | if err != nil { 15 | return nil, nil, err 16 | } 17 | 18 | sname, err := ptsname(p) 19 | if err != nil { 20 | return nil, nil, err 21 | } 22 | 23 | err = grantpt(p) 24 | if err != nil { 25 | return nil, nil, err 26 | } 27 | 28 | err = unlockpt(p) 29 | if err != nil { 30 | return nil, nil, err 31 | } 32 | 33 | t, err := os.OpenFile(sname, os.O_RDWR, 0) 34 | if err != nil { 35 | return nil, nil, err 36 | } 37 | return p, t, nil 38 | } 39 | 40 | func grantpt(f *os.File) error { 41 | _, err := isptmaster(f.Fd()) 42 | return err 43 | } 44 | 45 | func unlockpt(f *os.File) error { 46 | _, err := isptmaster(f.Fd()) 47 | return err 48 | } 49 | 50 | func isptmaster(fd uintptr) (bool, error) { 51 | err := ioctl(fd, syscall.TIOCISPTMASTER, 0) 52 | return err == nil, err 53 | } 54 | 55 | var ( 56 | emptyFiodgnameArg fiodgnameArg 57 | ioctl_FIODNAME = _IOW('f', 120, unsafe.Sizeof(emptyFiodgnameArg)) 58 | ) 59 | 60 | func ptsname(f *os.File) (string, error) { 61 | name := make([]byte, _C_SPECNAMELEN) 62 | fa := fiodgnameArg{Name: (*byte)(unsafe.Pointer(&name[0])), Len: _C_SPECNAMELEN, Pad_cgo_0: [4]byte{0, 0, 0, 0}} 63 | 64 | err := ioctl(f.Fd(), ioctl_FIODNAME, uintptr(unsafe.Pointer(&fa))) 65 | if err != nil { 66 | return "", err 67 | } 68 | 69 | for i, c := range name { 70 | if c == 0 { 71 | s := "/dev/" + string(name[:i]) 72 | return strings.Replace(s, "ptm", "pts", -1), nil 73 | } 74 | } 75 | return "", errors.New("TIOCPTYGNAME string not NUL-terminated") 76 | } 77 | -------------------------------------------------------------------------------- /vendor/github.com/op/go-logging/syslog.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013, Örjan Persson. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | //+build !windows,!plan9 6 | 7 | package logging 8 | 9 | import "log/syslog" 10 | 11 | // SyslogBackend is a simple logger to syslog backend. It automatically maps 12 | // the internal log levels to appropriate syslog log levels. 13 | type SyslogBackend struct { 14 | Writer *syslog.Writer 15 | } 16 | 17 | // NewSyslogBackend connects to the syslog daemon using UNIX sockets with the 18 | // given prefix. If prefix is not given, the prefix will be derived from the 19 | // launched command. 20 | func NewSyslogBackend(prefix string) (b *SyslogBackend, err error) { 21 | var w *syslog.Writer 22 | w, err = syslog.New(syslog.LOG_CRIT, prefix) 23 | return &SyslogBackend{w}, err 24 | } 25 | 26 | // NewSyslogBackendPriority is the same as NewSyslogBackend, but with custom 27 | // syslog priority, like syslog.LOG_LOCAL3|syslog.LOG_DEBUG etc. 28 | func NewSyslogBackendPriority(prefix string, priority syslog.Priority) (b *SyslogBackend, err error) { 29 | var w *syslog.Writer 30 | w, err = syslog.New(priority, prefix) 31 | return &SyslogBackend{w}, err 32 | } 33 | 34 | // Log implements the Backend interface. 35 | func (b *SyslogBackend) Log(level Level, calldepth int, rec *Record) error { 36 | line := rec.Formatted(calldepth + 1) 37 | switch level { 38 | case CRITICAL: 39 | return b.Writer.Crit(line) 40 | case ERROR: 41 | return b.Writer.Err(line) 42 | case WARNING: 43 | return b.Writer.Warning(line) 44 | case NOTICE: 45 | return b.Writer.Notice(line) 46 | case INFO: 47 | return b.Writer.Info(line) 48 | case DEBUG: 49 | return b.Writer.Debug(line) 50 | default: 51 | } 52 | panic("unhandled log level") 53 | } 54 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/mkpost.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build ignore 6 | 7 | // mkpost processes the output of cgo -godefs to 8 | // modify the generated types. It is used to clean up 9 | // the sys API in an architecture specific manner. 10 | // 11 | // mkpost is run after cgo -godefs by mkall.sh. 12 | package main 13 | 14 | import ( 15 | "fmt" 16 | "go/format" 17 | "io/ioutil" 18 | "log" 19 | "os" 20 | "regexp" 21 | ) 22 | 23 | func main() { 24 | b, err := ioutil.ReadAll(os.Stdin) 25 | if err != nil { 26 | log.Fatal(err) 27 | } 28 | s := string(b) 29 | 30 | goarch := os.Getenv("GOARCH") 31 | goos := os.Getenv("GOOS") 32 | if goarch == "s390x" && goos == "linux" { 33 | // Export the types of PtraceRegs fields. 34 | re := regexp.MustCompile("ptrace(Psw|Fpregs|Per)") 35 | s = re.ReplaceAllString(s, "Ptrace$1") 36 | 37 | // Replace padding fields inserted by cgo with blank identifiers. 38 | re = regexp.MustCompile("Pad_cgo[A-Za-z0-9_]*") 39 | s = re.ReplaceAllString(s, "_") 40 | 41 | // Replace other unwanted fields with blank identifiers. 42 | re = regexp.MustCompile("X_[A-Za-z0-9_]*") 43 | s = re.ReplaceAllString(s, "_") 44 | 45 | // Replace the control_regs union with a blank identifier for now. 46 | re = regexp.MustCompile("(Control_regs)\\s+\\[0\\]uint64") 47 | s = re.ReplaceAllString(s, "_ [0]uint64") 48 | } 49 | 50 | // gofmt 51 | b, err = format.Source([]byte(s)) 52 | if err != nil { 53 | log.Fatal(err) 54 | } 55 | 56 | // Append this command to the header to show where the new file 57 | // came from. 58 | re := regexp.MustCompile("(cgo -godefs [a-zA-Z0-9_]+\\.go.*)") 59 | b = re.ReplaceAll(b, []byte("$1 | go run mkpost.go")) 60 | 61 | fmt.Printf("%s", b) 62 | } 63 | -------------------------------------------------------------------------------- /vendor/github.com/kr/text/indent.go: -------------------------------------------------------------------------------- 1 | package text 2 | 3 | import ( 4 | "io" 5 | ) 6 | 7 | // Indent inserts prefix at the beginning of each non-empty line of s. The 8 | // end-of-line marker is NL. 9 | func Indent(s, prefix string) string { 10 | return string(IndentBytes([]byte(s), []byte(prefix))) 11 | } 12 | 13 | // IndentBytes inserts prefix at the beginning of each non-empty line of b. 14 | // The end-of-line marker is NL. 15 | func IndentBytes(b, prefix []byte) []byte { 16 | var res []byte 17 | bol := true 18 | for _, c := range b { 19 | if bol && c != '\n' { 20 | res = append(res, prefix...) 21 | } 22 | res = append(res, c) 23 | bol = c == '\n' 24 | } 25 | return res 26 | } 27 | 28 | // Writer indents each line of its input. 29 | type indentWriter struct { 30 | w io.Writer 31 | bol bool 32 | pre [][]byte 33 | sel int 34 | off int 35 | } 36 | 37 | // NewIndentWriter makes a new write filter that indents the input 38 | // lines. Each line is prefixed in order with the corresponding 39 | // element of pre. If there are more lines than elements, the last 40 | // element of pre is repeated for each subsequent line. 41 | func NewIndentWriter(w io.Writer, pre ...[]byte) io.Writer { 42 | return &indentWriter{ 43 | w: w, 44 | pre: pre, 45 | bol: true, 46 | } 47 | } 48 | 49 | // The only errors returned are from the underlying indentWriter. 50 | func (w *indentWriter) Write(p []byte) (n int, err error) { 51 | for _, c := range p { 52 | if w.bol { 53 | var i int 54 | i, err = w.w.Write(w.pre[w.sel][w.off:]) 55 | w.off += i 56 | if err != nil { 57 | return n, err 58 | } 59 | } 60 | _, err = w.w.Write([]byte{c}) 61 | if err != nil { 62 | return n, err 63 | } 64 | n++ 65 | w.bol = c == '\n' 66 | if w.bol { 67 | w.off = 0 68 | if w.sel < len(w.pre)-1 { 69 | w.sel++ 70 | } 71 | } 72 | } 73 | return n, nil 74 | } 75 | -------------------------------------------------------------------------------- /vendor/github.com/kr/text/cmd/agg/string.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "math/rand" 5 | "strings" 6 | ) 7 | 8 | func first(s, arg string) agg { return &sbinop{s, opfirst} } 9 | func last(s, arg string) agg { return &sbinop{s, oplast} } 10 | func prefix(s, arg string) agg { return &sbinop{s, opprefix} } 11 | func join(s, arg string) agg { return &sbinop{s, opjoin(arg)} } 12 | func smin(s, arg string) agg { return &sbinop{s, opsmin} } 13 | func smax(s, arg string) agg { return &sbinop{s, opsmax} } 14 | 15 | type sbinop struct { 16 | s string 17 | f func(a, b string) string 18 | } 19 | 20 | func (o *sbinop) String() string { return o.s } 21 | 22 | func (o *sbinop) merge(s string) { o.s = o.f(o.s, s) } 23 | 24 | func opfirst(a, b string) string { return a } 25 | func oplast(a, b string) string { return b } 26 | 27 | func opprefix(a, b string) string { 28 | for i := range a { 29 | if i >= len(b) || a[i] != b[i] { 30 | return a[:i] 31 | } 32 | } 33 | return a 34 | } 35 | 36 | func opjoin(sep string) func(a, b string) string { 37 | return func(a, b string) string { 38 | return a + sep + b // TODO(kr): too slow? maybe strings.Join? 39 | } 40 | } 41 | 42 | func opsmin(a, b string) string { 43 | if strings.Compare(a, b) <= 0 { 44 | return a 45 | } 46 | return b 47 | } 48 | 49 | func opsmax(a, b string) string { 50 | if strings.Compare(a, b) >= 0 { 51 | return a 52 | } 53 | return b 54 | } 55 | 56 | type sampler struct { 57 | n int 58 | s string 59 | } 60 | 61 | func sample(s, arg string) agg { return &sampler{1, s} } 62 | func (p *sampler) String() string { return p.s } 63 | func (p *sampler) merge(s string) { 64 | p.n++ 65 | if rand.Intn(p.n) == 0 { 66 | p.s = s 67 | } 68 | } 69 | 70 | type constant string 71 | 72 | func constf(init, arg string) agg { return constant(arg) } 73 | func (c constant) String() string { return string(c) } 74 | func (c constant) merge(string) {} 75 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package unix 6 | 7 | import ( 8 | "syscall" 9 | "unsafe" 10 | ) 11 | 12 | func Getpagesize() int { return 4096 } 13 | 14 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 15 | 16 | func NsecToTimespec(nsec int64) (ts Timespec) { 17 | ts.Sec = int32(nsec / 1e9) 18 | ts.Nsec = int32(nsec % 1e9) 19 | return 20 | } 21 | 22 | func NsecToTimeval(nsec int64) (tv Timeval) { 23 | nsec += 999 // round up to microsecond 24 | tv.Usec = int32(nsec % 1e9 / 1e3) 25 | tv.Sec = int32(nsec / 1e9) 26 | return 27 | } 28 | 29 | //sysnb gettimeofday(tp *Timeval) (sec int32, usec int32, err error) 30 | func Gettimeofday(tv *Timeval) (err error) { 31 | // The tv passed to gettimeofday must be non-nil 32 | // but is otherwise unused. The answers come back 33 | // in the two registers. 34 | sec, usec, err := gettimeofday(tv) 35 | tv.Sec = int32(sec) 36 | tv.Usec = int32(usec) 37 | return err 38 | } 39 | 40 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 41 | k.Ident = uint32(fd) 42 | k.Filter = int16(mode) 43 | k.Flags = uint16(flags) 44 | } 45 | 46 | func (iov *Iovec) SetLen(length int) { 47 | iov.Len = uint32(length) 48 | } 49 | 50 | func (msghdr *Msghdr) SetControllen(length int) { 51 | msghdr.Controllen = uint32(length) 52 | } 53 | 54 | func (cmsg *Cmsghdr) SetLen(length int) { 55 | cmsg.Len = uint32(length) 56 | } 57 | 58 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 59 | var length = uint64(count) 60 | 61 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(*offset>>32), uintptr(unsafe.Pointer(&length)), 0, 0, 0, 0) 62 | 63 | written = int(length) 64 | 65 | if e1 != 0 { 66 | err = e1 67 | } 68 | return 69 | } 70 | 71 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic 72 | -------------------------------------------------------------------------------- /vendor/github.com/cheggaaa/pb/format.go: -------------------------------------------------------------------------------- 1 | package pb 2 | 3 | import ( 4 | "fmt" 5 | "strings" 6 | "time" 7 | ) 8 | 9 | type Units int 10 | 11 | const ( 12 | // U_NO are default units, they represent a simple value and are not formatted at all. 13 | U_NO Units = iota 14 | // U_BYTES units are formatted in a human readable way (b, Bb, Mb, ...) 15 | U_BYTES 16 | // U_DURATION units are formatted in a human readable way (3h14m15s) 17 | U_DURATION 18 | ) 19 | 20 | func Format(i int64) *formatter { 21 | return &formatter{n: i} 22 | } 23 | 24 | type formatter struct { 25 | n int64 26 | unit Units 27 | width int 28 | perSec bool 29 | } 30 | 31 | func (f *formatter) Value(n int64) *formatter { 32 | f.n = n 33 | return f 34 | } 35 | 36 | func (f *formatter) To(unit Units) *formatter { 37 | f.unit = unit 38 | return f 39 | } 40 | 41 | func (f *formatter) Width(width int) *formatter { 42 | f.width = width 43 | return f 44 | } 45 | 46 | func (f *formatter) PerSec() *formatter { 47 | f.perSec = true 48 | return f 49 | } 50 | 51 | func (f *formatter) String() (out string) { 52 | switch f.unit { 53 | case U_BYTES: 54 | out = formatBytes(f.n) 55 | case U_DURATION: 56 | d := time.Duration(f.n) 57 | if d > time.Hour*24 { 58 | out = fmt.Sprintf("%dd", d/24/time.Hour) 59 | d -= (d / time.Hour / 24) * (time.Hour * 24) 60 | } 61 | out = fmt.Sprintf("%s%v", out, d) 62 | default: 63 | out = fmt.Sprintf(fmt.Sprintf("%%%dd", f.width), f.n) 64 | } 65 | if f.perSec { 66 | out += "/s" 67 | } 68 | return 69 | } 70 | 71 | // Convert bytes to human readable string. Like a 2 MB, 64.2 KB, 52 B 72 | func formatBytes(i int64) (result string) { 73 | switch { 74 | case i > (1024 * 1024 * 1024 * 1024): 75 | result = fmt.Sprintf("%.02f TB", float64(i)/1024/1024/1024/1024) 76 | case i > (1024 * 1024 * 1024): 77 | result = fmt.Sprintf("%.02f GB", float64(i)/1024/1024/1024) 78 | case i > (1024 * 1024): 79 | result = fmt.Sprintf("%.02f MB", float64(i)/1024/1024) 80 | case i > 1024: 81 | result = fmt.Sprintf("%.02f KB", float64(i)/1024) 82 | default: 83 | result = fmt.Sprintf("%d B", i) 84 | } 85 | result = strings.Trim(result, " ") 86 | return 87 | } 88 | -------------------------------------------------------------------------------- /vendor/gopkg.in/cheggaaa/pb.v1/format.go: -------------------------------------------------------------------------------- 1 | package pb 2 | 3 | import ( 4 | "fmt" 5 | "strings" 6 | "time" 7 | ) 8 | 9 | type Units int 10 | 11 | const ( 12 | // U_NO are default units, they represent a simple value and are not formatted at all. 13 | U_NO Units = iota 14 | // U_BYTES units are formatted in a human readable way (b, Bb, Mb, ...) 15 | U_BYTES 16 | // U_DURATION units are formatted in a human readable way (3h14m15s) 17 | U_DURATION 18 | ) 19 | 20 | func Format(i int64) *formatter { 21 | return &formatter{n: i} 22 | } 23 | 24 | type formatter struct { 25 | n int64 26 | unit Units 27 | width int 28 | perSec bool 29 | } 30 | 31 | func (f *formatter) Value(n int64) *formatter { 32 | f.n = n 33 | return f 34 | } 35 | 36 | func (f *formatter) To(unit Units) *formatter { 37 | f.unit = unit 38 | return f 39 | } 40 | 41 | func (f *formatter) Width(width int) *formatter { 42 | f.width = width 43 | return f 44 | } 45 | 46 | func (f *formatter) PerSec() *formatter { 47 | f.perSec = true 48 | return f 49 | } 50 | 51 | func (f *formatter) String() (out string) { 52 | switch f.unit { 53 | case U_BYTES: 54 | out = formatBytes(f.n) 55 | case U_DURATION: 56 | d := time.Duration(f.n) 57 | if d > time.Hour*24 { 58 | out = fmt.Sprintf("%dd", d/24/time.Hour) 59 | d -= (d / time.Hour / 24) * (time.Hour * 24) 60 | } 61 | out = fmt.Sprintf("%s%v", out, d) 62 | default: 63 | out = fmt.Sprintf(fmt.Sprintf("%%%dd", f.width), f.n) 64 | } 65 | if f.perSec { 66 | out += "/s" 67 | } 68 | return 69 | } 70 | 71 | // Convert bytes to human readable string. Like a 2 MB, 64.2 KB, 52 B 72 | func formatBytes(i int64) (result string) { 73 | switch { 74 | case i > (1024 * 1024 * 1024 * 1024): 75 | result = fmt.Sprintf("%.02f TB", float64(i)/1024/1024/1024/1024) 76 | case i > (1024 * 1024 * 1024): 77 | result = fmt.Sprintf("%.02f GB", float64(i)/1024/1024/1024) 78 | case i > (1024 * 1024): 79 | result = fmt.Sprintf("%.02f MB", float64(i)/1024/1024) 80 | case i > 1024: 81 | result = fmt.Sprintf("%.02f KB", float64(i)/1024) 82 | default: 83 | result = fmt.Sprintf("%d B", i) 84 | } 85 | result = strings.Trim(result, " ") 86 | return 87 | } 88 | -------------------------------------------------------------------------------- /vendor/github.com/op/go-logging/multi.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013, Örjan Persson. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package logging 6 | 7 | // TODO remove Level stuff from the multi logger. Do one thing. 8 | 9 | // multiLogger is a log multiplexer which can be used to utilize multiple log 10 | // backends at once. 11 | type multiLogger struct { 12 | backends []LeveledBackend 13 | } 14 | 15 | // MultiLogger creates a logger which contain multiple loggers. 16 | func MultiLogger(backends ...Backend) LeveledBackend { 17 | var leveledBackends []LeveledBackend 18 | for _, backend := range backends { 19 | leveledBackends = append(leveledBackends, AddModuleLevel(backend)) 20 | } 21 | return &multiLogger{leveledBackends} 22 | } 23 | 24 | // Log passes the log record to all backends. 25 | func (b *multiLogger) Log(level Level, calldepth int, rec *Record) (err error) { 26 | for _, backend := range b.backends { 27 | if backend.IsEnabledFor(level, rec.Module) { 28 | // Shallow copy of the record for the formatted cache on Record and get the 29 | // record formatter from the backend. 30 | r2 := *rec 31 | if e := backend.Log(level, calldepth+1, &r2); e != nil { 32 | err = e 33 | } 34 | } 35 | } 36 | return 37 | } 38 | 39 | // GetLevel returns the highest level enabled by all backends. 40 | func (b *multiLogger) GetLevel(module string) Level { 41 | var level Level 42 | for _, backend := range b.backends { 43 | if backendLevel := backend.GetLevel(module); backendLevel > level { 44 | level = backendLevel 45 | } 46 | } 47 | return level 48 | } 49 | 50 | // SetLevel propagates the same level to all backends. 51 | func (b *multiLogger) SetLevel(level Level, module string) { 52 | for _, backend := range b.backends { 53 | backend.SetLevel(level, module) 54 | } 55 | } 56 | 57 | // IsEnabledFor returns true if any of the backends are enabled for it. 58 | func (b *multiLogger) IsEnabledFor(level Level, module string) bool { 59 | for _, backend := range b.backends { 60 | if backend.IsEnabledFor(level, module) { 61 | return true 62 | } 63 | } 64 | return false 65 | } 66 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin_arm64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build arm64,darwin 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 16384 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = nsec / 1e9 20 | ts.Nsec = nsec % 1e9 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = int32(nsec % 1e9 / 1e3) 27 | tv.Sec = int64(nsec / 1e9) 28 | return 29 | } 30 | 31 | //sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error) 32 | func Gettimeofday(tv *Timeval) (err error) { 33 | // The tv passed to gettimeofday must be non-nil 34 | // but is otherwise unused. The answers come back 35 | // in the two registers. 36 | sec, usec, err := gettimeofday(tv) 37 | tv.Sec = sec 38 | tv.Usec = usec 39 | return err 40 | } 41 | 42 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 43 | k.Ident = uint64(fd) 44 | k.Filter = int16(mode) 45 | k.Flags = uint16(flags) 46 | } 47 | 48 | func (iov *Iovec) SetLen(length int) { 49 | iov.Len = uint64(length) 50 | } 51 | 52 | func (msghdr *Msghdr) SetControllen(length int) { 53 | msghdr.Controllen = uint32(length) 54 | } 55 | 56 | func (cmsg *Cmsghdr) SetLen(length int) { 57 | cmsg.Len = uint32(length) 58 | } 59 | 60 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 61 | var length = uint64(count) 62 | 63 | _, _, e1 := Syscall6(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(unsafe.Pointer(&length)), 0, 0) 64 | 65 | written = int(length) 66 | 67 | if e1 != 0 { 68 | err = e1 69 | } 70 | return 71 | } 72 | 73 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic 74 | 75 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 76 | // of darwin/arm64 the syscall is called sysctl instead of __sysctl. 77 | const SYS___SYSCTL = SYS_SYSCTL 78 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build 386,darwin 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = int32(nsec / 1e9) 20 | ts.Nsec = int32(nsec % 1e9) 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = int32(nsec % 1e9 / 1e3) 27 | tv.Sec = int32(nsec / 1e9) 28 | return 29 | } 30 | 31 | //sysnb gettimeofday(tp *Timeval) (sec int32, usec int32, err error) 32 | func Gettimeofday(tv *Timeval) (err error) { 33 | // The tv passed to gettimeofday must be non-nil 34 | // but is otherwise unused. The answers come back 35 | // in the two registers. 36 | sec, usec, err := gettimeofday(tv) 37 | tv.Sec = int32(sec) 38 | tv.Usec = int32(usec) 39 | return err 40 | } 41 | 42 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 43 | k.Ident = uint32(fd) 44 | k.Filter = int16(mode) 45 | k.Flags = uint16(flags) 46 | } 47 | 48 | func (iov *Iovec) SetLen(length int) { 49 | iov.Len = uint32(length) 50 | } 51 | 52 | func (msghdr *Msghdr) SetControllen(length int) { 53 | msghdr.Controllen = uint32(length) 54 | } 55 | 56 | func (cmsg *Cmsghdr) SetLen(length int) { 57 | cmsg.Len = uint32(length) 58 | } 59 | 60 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 61 | var length = uint64(count) 62 | 63 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(*offset>>32), uintptr(unsafe.Pointer(&length)), 0, 0, 0, 0) 64 | 65 | written = int(length) 66 | 67 | if e1 != 0 { 68 | err = e1 69 | } 70 | return 71 | } 72 | 73 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 74 | 75 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 76 | // of darwin/386 the syscall is called sysctl instead of __sysctl. 77 | const SYS___SYSCTL = SYS_SYSCTL 78 | -------------------------------------------------------------------------------- /vendor/github.com/kr/text/cmd/agg/num.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "math/big" 5 | "strconv" 6 | ) 7 | 8 | func min(s, arg string) agg { return newBinop(s, opmin) } 9 | func max(s, arg string) agg { return newBinop(s, opmax) } 10 | func sum(s, arg string) agg { return newBinop(s, opsum) } 11 | 12 | type binop struct { 13 | v *big.Float 14 | f func(a, b *big.Float) *big.Float 15 | } 16 | 17 | func newBinop(s string, f func(a, b *big.Float) *big.Float) *binop { 18 | v, _ := parseFloat(s) 19 | return &binop{v, f} 20 | } 21 | 22 | func (o *binop) String() string { 23 | if o.v == nil { 24 | return "NaN" 25 | } 26 | return o.v.Text('f', -1) 27 | } 28 | 29 | func (o *binop) merge(s string) { 30 | v, ok := parseFloat(s) 31 | if !ok { 32 | return 33 | } 34 | o.v = o.f(o.v, v) 35 | } 36 | 37 | func opmin(a, b *big.Float) *big.Float { 38 | if a != nil && (b == nil || a.Cmp(b) <= 0) { 39 | return a 40 | } 41 | return b 42 | } 43 | 44 | func opmax(a, b *big.Float) *big.Float { 45 | if a != nil && (b == nil || a.Cmp(b) >= 0) { 46 | return a 47 | } 48 | return b 49 | } 50 | 51 | func opsum(a, b *big.Float) *big.Float { 52 | if a == nil { 53 | return b 54 | } else if b == nil { 55 | return a 56 | } 57 | return a.Add(a, b) 58 | } 59 | 60 | type meanagg struct { 61 | v *big.Float 62 | d float64 // actually an integer 63 | } 64 | 65 | func mean(s, arg string) agg { 66 | v, ok := parseFloat(s) 67 | if !ok { 68 | return &meanagg{new(big.Float), 0} 69 | } 70 | return &meanagg{v, 1} 71 | } 72 | 73 | func (m *meanagg) String() string { 74 | if m.d == 0 { 75 | return "NaN" 76 | } 77 | v := new(big.Float).Quo(m.v, big.NewFloat(m.d)) 78 | return v.Text('f', -1) 79 | } 80 | 81 | func (m *meanagg) merge(s string) { 82 | v, ok := parseFloat(s) 83 | if !ok { 84 | return 85 | } 86 | m.v.Add(m.v, v) 87 | m.d++ 88 | } 89 | 90 | func parseFloat(s string) (*big.Float, bool) { 91 | v, _, err := big.ParseFloat(s, 0, 1000, big.ToNearestEven) 92 | return v, err == nil 93 | } 94 | 95 | type counter int 96 | 97 | func count(init, arg string) agg { return new(counter) } 98 | func (c *counter) String() string { return strconv.Itoa(int(*c) + 1) } 99 | func (c *counter) merge(string) { *c++ } 100 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,darwin 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | //sys Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) 15 | 16 | func Getpagesize() int { return 4096 } 17 | 18 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 19 | 20 | func NsecToTimespec(nsec int64) (ts Timespec) { 21 | ts.Sec = nsec / 1e9 22 | ts.Nsec = nsec % 1e9 23 | return 24 | } 25 | 26 | func NsecToTimeval(nsec int64) (tv Timeval) { 27 | nsec += 999 // round up to microsecond 28 | tv.Usec = int32(nsec % 1e9 / 1e3) 29 | tv.Sec = int64(nsec / 1e9) 30 | return 31 | } 32 | 33 | //sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error) 34 | func Gettimeofday(tv *Timeval) (err error) { 35 | // The tv passed to gettimeofday must be non-nil 36 | // but is otherwise unused. The answers come back 37 | // in the two registers. 38 | sec, usec, err := gettimeofday(tv) 39 | tv.Sec = sec 40 | tv.Usec = usec 41 | return err 42 | } 43 | 44 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 45 | k.Ident = uint64(fd) 46 | k.Filter = int16(mode) 47 | k.Flags = uint16(flags) 48 | } 49 | 50 | func (iov *Iovec) SetLen(length int) { 51 | iov.Len = uint64(length) 52 | } 53 | 54 | func (msghdr *Msghdr) SetControllen(length int) { 55 | msghdr.Controllen = uint32(length) 56 | } 57 | 58 | func (cmsg *Cmsghdr) SetLen(length int) { 59 | cmsg.Len = uint32(length) 60 | } 61 | 62 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 63 | var length = uint64(count) 64 | 65 | _, _, e1 := Syscall6(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(unsafe.Pointer(&length)), 0, 0) 66 | 67 | written = int(length) 68 | 69 | if e1 != 0 { 70 | err = e1 71 | } 72 | return 73 | } 74 | 75 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 76 | 77 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 78 | // of darwin/amd64 the syscall is called sysctl instead of __sysctl. 79 | const SYS___SYSCTL = SYS_SYSCTL 80 | -------------------------------------------------------------------------------- /vendor/github.com/kr/text/cmd/agg/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | // TODO(kr): tests 4 | 5 | import ( 6 | "bufio" 7 | "fmt" 8 | "log" 9 | "math/rand" 10 | "os" 11 | "strings" 12 | "time" 13 | ) 14 | 15 | type agg interface { 16 | merge(string) 17 | String() string 18 | } 19 | 20 | var ( 21 | key = 0 22 | funcmap = make(map[int]func(init, arg string) agg) 23 | argmap = make(map[int]string) 24 | symtab = map[string]func(init, arg string) agg{ 25 | "first": first, 26 | "last": last, 27 | "prefix": prefix, 28 | "sample": sample, 29 | "join": join, 30 | "smin": smin, 31 | "smax": smax, 32 | "min": min, 33 | "max": max, 34 | "sum": sum, 35 | "mean": mean, 36 | "count": count, 37 | "const": constf, 38 | "drop": nil, 39 | } 40 | ) 41 | 42 | func main() { 43 | log.SetPrefix("agg: ") 44 | log.SetFlags(0) 45 | rand.Seed(time.Now().UnixNano()) 46 | for i, sym := range os.Args[1:] { 47 | if p := strings.IndexByte(sym, ':'); p >= 0 { 48 | sym, argmap[i] = sym[:p], sym[p+1:] 49 | } 50 | if sym == "key" { 51 | key, sym = i, "first" 52 | } 53 | f, ok := symtab[sym] 54 | if !ok { 55 | log.Fatalf("bad function: %q", sym) 56 | } 57 | funcmap[i] = f 58 | } 59 | 60 | sc := bufio.NewScanner(os.Stdin) 61 | var g *group 62 | for sc.Scan() { 63 | ss := strings.Fields(sc.Text()) 64 | if !matches(g, ss) { 65 | emit(g) 66 | g = &group{key: ss[key]} 67 | } 68 | mergeLine(g, ss) 69 | } 70 | emit(g) 71 | } 72 | 73 | type group struct { 74 | key string 75 | agg []agg 76 | } 77 | 78 | func matches(g *group, ss []string) bool { 79 | return g != nil && g.key == ss[key] 80 | } 81 | 82 | func emit(g *group) { 83 | if g == nil { 84 | return 85 | } 86 | rest := false 87 | for i, a := range g.agg { 88 | if f, ok := funcmap[i]; ok && f == nil { 89 | continue 90 | } 91 | if rest { 92 | fmt.Print("\t") 93 | } 94 | rest = true 95 | fmt.Print(a) 96 | } 97 | fmt.Println() 98 | } 99 | 100 | func mergeLine(g *group, ss []string) { 101 | for i, s := range ss { 102 | if i >= len(g.agg) { 103 | f := funcmap[i] 104 | if f == nil { 105 | f = first 106 | } 107 | g.agg = append(g.agg, f(s, argmap[i])) 108 | } else { 109 | g.agg[i].merge(s) 110 | } 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /vendor/github.com/BurntSushi/toml/cmd/toml-test-decoder/main.go: -------------------------------------------------------------------------------- 1 | // Command toml-test-decoder satisfies the toml-test interface for testing 2 | // TOML decoders. Namely, it accepts TOML on stdin and outputs JSON on stdout. 3 | package main 4 | 5 | import ( 6 | "encoding/json" 7 | "flag" 8 | "fmt" 9 | "log" 10 | "os" 11 | "path" 12 | "time" 13 | 14 | "github.com/BurntSushi/toml" 15 | ) 16 | 17 | func init() { 18 | log.SetFlags(0) 19 | 20 | flag.Usage = usage 21 | flag.Parse() 22 | } 23 | 24 | func usage() { 25 | log.Printf("Usage: %s < toml-file\n", path.Base(os.Args[0])) 26 | flag.PrintDefaults() 27 | 28 | os.Exit(1) 29 | } 30 | 31 | func main() { 32 | if flag.NArg() != 0 { 33 | flag.Usage() 34 | } 35 | 36 | var tmp interface{} 37 | if _, err := toml.DecodeReader(os.Stdin, &tmp); err != nil { 38 | log.Fatalf("Error decoding TOML: %s", err) 39 | } 40 | 41 | typedTmp := translate(tmp) 42 | if err := json.NewEncoder(os.Stdout).Encode(typedTmp); err != nil { 43 | log.Fatalf("Error encoding JSON: %s", err) 44 | } 45 | } 46 | 47 | func translate(tomlData interface{}) interface{} { 48 | switch orig := tomlData.(type) { 49 | case map[string]interface{}: 50 | typed := make(map[string]interface{}, len(orig)) 51 | for k, v := range orig { 52 | typed[k] = translate(v) 53 | } 54 | return typed 55 | case []map[string]interface{}: 56 | typed := make([]map[string]interface{}, len(orig)) 57 | for i, v := range orig { 58 | typed[i] = translate(v).(map[string]interface{}) 59 | } 60 | return typed 61 | case []interface{}: 62 | typed := make([]interface{}, len(orig)) 63 | for i, v := range orig { 64 | typed[i] = translate(v) 65 | } 66 | 67 | // We don't really need to tag arrays, but let's be future proof. 68 | // (If TOML ever supports tuples, we'll need this.) 69 | return tag("array", typed) 70 | case time.Time: 71 | return tag("datetime", orig.Format("2006-01-02T15:04:05Z")) 72 | case bool: 73 | return tag("bool", fmt.Sprintf("%v", orig)) 74 | case int64: 75 | return tag("integer", fmt.Sprintf("%d", orig)) 76 | case float64: 77 | return tag("float", fmt.Sprintf("%v", orig)) 78 | case string: 79 | return tag("string", orig) 80 | } 81 | 82 | panic(fmt.Sprintf("Unknown type: %T", tomlData)) 83 | } 84 | 85 | func tag(typeName string, data interface{}) map[string]interface{} { 86 | return map[string]interface{}{ 87 | "type": typeName, 88 | "value": data, 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /cmd/cluster.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | json "github.com/dutchcoders/elastico/json" 5 | 6 | "github.com/codegangsta/cli" 7 | ) 8 | 9 | var ( 10 | _ = registerTemplate("cluster:state", `=== Cluster state 11 | cluster name {{ .cluster_name }} 12 | master node {{ .master_node }} 13 | 14 | = Nodes 15 | {{range $name, $node := .nodes -}} 16 | {{ $name }} {{ $node.name }} {{ $node.transport_address }} 17 | {{end}} 18 | `) 19 | _ = registerTemplate("cluster:health", `=== Cluster health 20 | name {{ .cluster_name }} 21 | {{- if eq .status "green" }} 22 | status {{ .status | green }} 23 | {{ end -}} 24 | {{- if eq .status "yellow" }} 25 | status {{ .status | yellow }} 26 | {{ end -}} 27 | {{- if eq .status "red" }} 28 | status {{ .status | red }} 29 | {{ end -}} 30 | # nodes {{ .number_of_nodes }} 31 | # data nodes {{ .number_of_data_nodes }} 32 | # active shards {{ .active_shards }} 33 | # active primary shards {{ .active_primary_shards }} 34 | # initializing shards {{ .initializing_shards }} 35 | # relocating shards {{ .relocating_shards }} 36 | # unassigned shards {{ .unassigned_shards }} 37 | `) 38 | ) 39 | 40 | var clusterCmds = []cli.Command{ 41 | cli.Command{ 42 | Name: "cluster:state", 43 | Usage: "Retrieve cluster state", 44 | Description: ``, 45 | Action: run(runClusterState), 46 | Flags: []cli.Flag{}, 47 | }, 48 | cli.Command{ 49 | Name: "cluster:health", 50 | Usage: "Retrieve cluster health", 51 | Description: ``, 52 | Action: run(runClusterHealth), 53 | Flags: []cli.Flag{ 54 | cli.StringFlag{ 55 | Name: "type", 56 | Value: "fs", 57 | }, 58 | cli.BoolFlag{ 59 | Name: "compress", 60 | }, 61 | cli.StringFlag{ 62 | Name: "location", 63 | }, 64 | }, 65 | }, 66 | } 67 | 68 | func runClusterState(c *cli.Context) (json.M, error) { 69 | req, err := e.NewRequest("GET", "/_cluster/state", nil) 70 | if err != nil { 71 | return nil, err 72 | } 73 | 74 | var resp json.M 75 | if err := e.Do(req, &resp); err != nil { 76 | return nil, err 77 | } 78 | 79 | return resp, nil 80 | } 81 | 82 | func runClusterHealth(c *cli.Context) (json.M, error) { 83 | req, err := e.NewRequest("GET", "/_cluster/health", nil) 84 | if err != nil { 85 | return nil, err 86 | } 87 | 88 | var resp json.M 89 | if err := e.Do(req, &resp); err != nil { 90 | return nil, err 91 | } 92 | 93 | return resp, nil 94 | } 95 | -------------------------------------------------------------------------------- /vendor/gopkg.in/check.v1/reporter.go: -------------------------------------------------------------------------------- 1 | package check 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | "sync" 7 | ) 8 | 9 | // ----------------------------------------------------------------------- 10 | // Output writer manages atomic output writing according to settings. 11 | 12 | type outputWriter struct { 13 | m sync.Mutex 14 | writer io.Writer 15 | wroteCallProblemLast bool 16 | Stream bool 17 | Verbose bool 18 | } 19 | 20 | func newOutputWriter(writer io.Writer, stream, verbose bool) *outputWriter { 21 | return &outputWriter{writer: writer, Stream: stream, Verbose: verbose} 22 | } 23 | 24 | func (ow *outputWriter) Write(content []byte) (n int, err error) { 25 | ow.m.Lock() 26 | n, err = ow.writer.Write(content) 27 | ow.m.Unlock() 28 | return 29 | } 30 | 31 | func (ow *outputWriter) WriteCallStarted(label string, c *C) { 32 | if ow.Stream { 33 | header := renderCallHeader(label, c, "", "\n") 34 | ow.m.Lock() 35 | ow.writer.Write([]byte(header)) 36 | ow.m.Unlock() 37 | } 38 | } 39 | 40 | func (ow *outputWriter) WriteCallProblem(label string, c *C) { 41 | var prefix string 42 | if !ow.Stream { 43 | prefix = "\n-----------------------------------" + 44 | "-----------------------------------\n" 45 | } 46 | header := renderCallHeader(label, c, prefix, "\n\n") 47 | ow.m.Lock() 48 | ow.wroteCallProblemLast = true 49 | ow.writer.Write([]byte(header)) 50 | if !ow.Stream { 51 | c.logb.WriteTo(ow.writer) 52 | } 53 | ow.m.Unlock() 54 | } 55 | 56 | func (ow *outputWriter) WriteCallSuccess(label string, c *C) { 57 | if ow.Stream || (ow.Verbose && c.kind == testKd) { 58 | // TODO Use a buffer here. 59 | var suffix string 60 | if c.reason != "" { 61 | suffix = " (" + c.reason + ")" 62 | } 63 | if c.status() == succeededSt { 64 | suffix += "\t" + c.timerString() 65 | } 66 | suffix += "\n" 67 | if ow.Stream { 68 | suffix += "\n" 69 | } 70 | header := renderCallHeader(label, c, "", suffix) 71 | ow.m.Lock() 72 | // Resist temptation of using line as prefix above due to race. 73 | if !ow.Stream && ow.wroteCallProblemLast { 74 | header = "\n-----------------------------------" + 75 | "-----------------------------------\n" + 76 | header 77 | } 78 | ow.wroteCallProblemLast = false 79 | ow.writer.Write([]byte(header)) 80 | ow.m.Unlock() 81 | } 82 | } 83 | 84 | func renderCallHeader(label string, c *C, prefix, suffix string) string { 85 | pc := c.method.PC() 86 | return fmt.Sprintf("%s%s: %s: %s%s", prefix, label, niceFuncPath(pc), 87 | niceFuncName(pc), suffix) 88 | } 89 | -------------------------------------------------------------------------------- /vendor/github.com/dustin/go-humanize/comma.go: -------------------------------------------------------------------------------- 1 | package humanize 2 | 3 | import ( 4 | "bytes" 5 | "math/big" 6 | "strconv" 7 | "strings" 8 | ) 9 | 10 | // Comma produces a string form of the given number in base 10 with 11 | // commas after every three orders of magnitude. 12 | // 13 | // e.g. Comma(834142) -> 834,142 14 | func Comma(v int64) string { 15 | sign := "" 16 | if v < 0 { 17 | sign = "-" 18 | v = 0 - v 19 | } 20 | 21 | parts := []string{"", "", "", "", "", "", ""} 22 | j := len(parts) - 1 23 | 24 | for v > 999 { 25 | parts[j] = strconv.FormatInt(v%1000, 10) 26 | switch len(parts[j]) { 27 | case 2: 28 | parts[j] = "0" + parts[j] 29 | case 1: 30 | parts[j] = "00" + parts[j] 31 | } 32 | v = v / 1000 33 | j-- 34 | } 35 | parts[j] = strconv.Itoa(int(v)) 36 | return sign + strings.Join(parts[j:], ",") 37 | } 38 | 39 | // Commaf produces a string form of the given number in base 10 with 40 | // commas after every three orders of magnitude. 41 | // 42 | // e.g. Commaf(834142.32) -> 834,142.32 43 | func Commaf(v float64) string { 44 | buf := &bytes.Buffer{} 45 | if v < 0 { 46 | buf.Write([]byte{'-'}) 47 | v = 0 - v 48 | } 49 | 50 | comma := []byte{','} 51 | 52 | parts := strings.Split(strconv.FormatFloat(v, 'f', -1, 64), ".") 53 | pos := 0 54 | if len(parts[0])%3 != 0 { 55 | pos += len(parts[0]) % 3 56 | buf.WriteString(parts[0][:pos]) 57 | buf.Write(comma) 58 | } 59 | for ; pos < len(parts[0]); pos += 3 { 60 | buf.WriteString(parts[0][pos : pos+3]) 61 | buf.Write(comma) 62 | } 63 | buf.Truncate(buf.Len() - 1) 64 | 65 | if len(parts) > 1 { 66 | buf.Write([]byte{'.'}) 67 | buf.WriteString(parts[1]) 68 | } 69 | return buf.String() 70 | } 71 | 72 | // BigComma produces a string form of the given big.Int in base 10 73 | // with commas after every three orders of magnitude. 74 | func BigComma(b *big.Int) string { 75 | sign := "" 76 | if b.Sign() < 0 { 77 | sign = "-" 78 | b.Abs(b) 79 | } 80 | 81 | athousand := big.NewInt(1000) 82 | c := (&big.Int{}).Set(b) 83 | _, m := oom(c, athousand) 84 | parts := make([]string, m+1) 85 | j := len(parts) - 1 86 | 87 | mod := &big.Int{} 88 | for b.Cmp(athousand) >= 0 { 89 | b.DivMod(b, athousand, mod) 90 | parts[j] = strconv.FormatInt(mod.Int64(), 10) 91 | switch len(parts[j]) { 92 | case 2: 93 | parts[j] = "0" + parts[j] 94 | case 1: 95 | parts[j] = "00" + parts[j] 96 | } 97 | j-- 98 | } 99 | parts[j] = strconv.Itoa(int(b.Int64())) 100 | return sign + strings.Join(parts[j:], ",") 101 | } 102 | -------------------------------------------------------------------------------- /vendor/github.com/kr/text/wrap.go: -------------------------------------------------------------------------------- 1 | package text 2 | 3 | import ( 4 | "bytes" 5 | "math" 6 | ) 7 | 8 | var ( 9 | nl = []byte{'\n'} 10 | sp = []byte{' '} 11 | ) 12 | 13 | const defaultPenalty = 1e5 14 | 15 | // Wrap wraps s into a paragraph of lines of length lim, with minimal 16 | // raggedness. 17 | func Wrap(s string, lim int) string { 18 | return string(WrapBytes([]byte(s), lim)) 19 | } 20 | 21 | // WrapBytes wraps b into a paragraph of lines of length lim, with minimal 22 | // raggedness. 23 | func WrapBytes(b []byte, lim int) []byte { 24 | words := bytes.Split(bytes.Replace(bytes.TrimSpace(b), nl, sp, -1), sp) 25 | var lines [][]byte 26 | for _, line := range WrapWords(words, 1, lim, defaultPenalty) { 27 | lines = append(lines, bytes.Join(line, sp)) 28 | } 29 | return bytes.Join(lines, nl) 30 | } 31 | 32 | // WrapWords is the low-level line-breaking algorithm, useful if you need more 33 | // control over the details of the text wrapping process. For most uses, either 34 | // Wrap or WrapBytes will be sufficient and more convenient. 35 | // 36 | // WrapWords splits a list of words into lines with minimal "raggedness", 37 | // treating each byte as one unit, accounting for spc units between adjacent 38 | // words on each line, and attempting to limit lines to lim units. Raggedness 39 | // is the total error over all lines, where error is the square of the 40 | // difference of the length of the line and lim. Too-long lines (which only 41 | // happen when a single word is longer than lim units) have pen penalty units 42 | // added to the error. 43 | func WrapWords(words [][]byte, spc, lim, pen int) [][][]byte { 44 | n := len(words) 45 | 46 | length := make([][]int, n) 47 | for i := 0; i < n; i++ { 48 | length[i] = make([]int, n) 49 | length[i][i] = len(words[i]) 50 | for j := i + 1; j < n; j++ { 51 | length[i][j] = length[i][j-1] + spc + len(words[j]) 52 | } 53 | } 54 | 55 | nbrk := make([]int, n) 56 | cost := make([]int, n) 57 | for i := range cost { 58 | cost[i] = math.MaxInt32 59 | } 60 | for i := n - 1; i >= 0; i-- { 61 | if length[i][n-1] <= lim || i == n-1 { 62 | cost[i] = 0 63 | nbrk[i] = n 64 | } else { 65 | for j := i + 1; j < n; j++ { 66 | d := lim - length[i][j-1] 67 | c := d*d + cost[j] 68 | if length[i][j-1] > lim { 69 | c += pen // too-long lines get a worse penalty 70 | } 71 | if c < cost[i] { 72 | cost[i] = c 73 | nbrk[i] = j 74 | } 75 | } 76 | } 77 | } 78 | 79 | var lines [][][]byte 80 | i := 0 81 | for i < n { 82 | lines = append(lines, words[i:nbrk[i]]) 83 | i = nbrk[i] 84 | } 85 | return lines 86 | } 87 | -------------------------------------------------------------------------------- /vendor/github.com/urfave/cli/altsrc/yaml_file_loader.go: -------------------------------------------------------------------------------- 1 | // Disabling building of yaml support in cases where golang is 1.0 or 1.1 2 | // as the encoding library is not implemented or supported. 3 | 4 | // +build go1.2 5 | 6 | package altsrc 7 | 8 | import ( 9 | "fmt" 10 | "io/ioutil" 11 | "net/http" 12 | "net/url" 13 | "os" 14 | 15 | "github.com/urfave/cli" 16 | 17 | "gopkg.in/yaml.v2" 18 | ) 19 | 20 | type yamlSourceContext struct { 21 | FilePath string 22 | } 23 | 24 | // NewYamlSourceFromFile creates a new Yaml InputSourceContext from a filepath. 25 | func NewYamlSourceFromFile(file string) (InputSourceContext, error) { 26 | ysc := &yamlSourceContext{FilePath: file} 27 | var results map[interface{}]interface{} 28 | err := readCommandYaml(ysc.FilePath, &results) 29 | if err != nil { 30 | return nil, fmt.Errorf("Unable to load Yaml file '%s': inner error: \n'%v'", ysc.FilePath, err.Error()) 31 | } 32 | 33 | return &MapInputSource{valueMap: results}, nil 34 | } 35 | 36 | // NewYamlSourceFromFlagFunc creates a new Yaml InputSourceContext from a provided flag name and source context. 37 | func NewYamlSourceFromFlagFunc(flagFileName string) func(context *cli.Context) (InputSourceContext, error) { 38 | return func(context *cli.Context) (InputSourceContext, error) { 39 | filePath := context.String(flagFileName) 40 | return NewYamlSourceFromFile(filePath) 41 | } 42 | } 43 | 44 | func readCommandYaml(filePath string, container interface{}) (err error) { 45 | b, err := loadDataFrom(filePath) 46 | if err != nil { 47 | return err 48 | } 49 | 50 | err = yaml.Unmarshal(b, container) 51 | if err != nil { 52 | return err 53 | } 54 | 55 | err = nil 56 | return 57 | } 58 | 59 | func loadDataFrom(filePath string) ([]byte, error) { 60 | u, err := url.Parse(filePath) 61 | if err != nil { 62 | return nil, err 63 | } 64 | 65 | if u.Host != "" { // i have a host, now do i support the scheme? 66 | switch u.Scheme { 67 | case "http", "https": 68 | res, err := http.Get(filePath) 69 | if err != nil { 70 | return nil, err 71 | } 72 | return ioutil.ReadAll(res.Body) 73 | default: 74 | return nil, fmt.Errorf("scheme of %s is unsupported", filePath) 75 | } 76 | } else if u.Path != "" { // i dont have a host, but I have a path. I am a local file. 77 | if _, notFoundFileErr := os.Stat(filePath); notFoundFileErr != nil { 78 | return nil, fmt.Errorf("Cannot read from file: '%s' because it does not exist.", filePath) 79 | } 80 | return ioutil.ReadFile(filePath) 81 | } else { 82 | return nil, fmt.Errorf("unable to determine how to load from path %s", filePath) 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /vendor/github.com/codegangsta/cli/altsrc/yaml_file_loader.go: -------------------------------------------------------------------------------- 1 | // Disabling building of yaml support in cases where golang is 1.0 or 1.1 2 | // as the encoding library is not implemented or supported. 3 | 4 | // +build go1.2 5 | 6 | package altsrc 7 | 8 | import ( 9 | "fmt" 10 | "io/ioutil" 11 | "net/http" 12 | "net/url" 13 | "os" 14 | 15 | "github.com/urfave/cli" 16 | 17 | "gopkg.in/yaml.v2" 18 | ) 19 | 20 | type yamlSourceContext struct { 21 | FilePath string 22 | } 23 | 24 | // NewYamlSourceFromFile creates a new Yaml InputSourceContext from a filepath. 25 | func NewYamlSourceFromFile(file string) (InputSourceContext, error) { 26 | ysc := &yamlSourceContext{FilePath: file} 27 | var results map[interface{}]interface{} 28 | err := readCommandYaml(ysc.FilePath, &results) 29 | if err != nil { 30 | return nil, fmt.Errorf("Unable to load Yaml file '%s': inner error: \n'%v'", ysc.FilePath, err.Error()) 31 | } 32 | 33 | return &MapInputSource{valueMap: results}, nil 34 | } 35 | 36 | // NewYamlSourceFromFlagFunc creates a new Yaml InputSourceContext from a provided flag name and source context. 37 | func NewYamlSourceFromFlagFunc(flagFileName string) func(context *cli.Context) (InputSourceContext, error) { 38 | return func(context *cli.Context) (InputSourceContext, error) { 39 | filePath := context.String(flagFileName) 40 | return NewYamlSourceFromFile(filePath) 41 | } 42 | } 43 | 44 | func readCommandYaml(filePath string, container interface{}) (err error) { 45 | b, err := loadDataFrom(filePath) 46 | if err != nil { 47 | return err 48 | } 49 | 50 | err = yaml.Unmarshal(b, container) 51 | if err != nil { 52 | return err 53 | } 54 | 55 | err = nil 56 | return 57 | } 58 | 59 | func loadDataFrom(filePath string) ([]byte, error) { 60 | u, err := url.Parse(filePath) 61 | if err != nil { 62 | return nil, err 63 | } 64 | 65 | if u.Host != "" { // i have a host, now do i support the scheme? 66 | switch u.Scheme { 67 | case "http", "https": 68 | res, err := http.Get(filePath) 69 | if err != nil { 70 | return nil, err 71 | } 72 | return ioutil.ReadAll(res.Body) 73 | default: 74 | return nil, fmt.Errorf("scheme of %s is unsupported", filePath) 75 | } 76 | } else if u.Path != "" { // i dont have a host, but I have a path. I am a local file. 77 | if _, notFoundFileErr := os.Stat(filePath); notFoundFileErr != nil { 78 | return nil, fmt.Errorf("Cannot read from file: '%s' because it does not exist.", filePath) 79 | } 80 | return ioutil.ReadFile(filePath) 81 | } else { 82 | return nil, fmt.Errorf("unable to determine how to load from path %s", filePath) 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /vendor/github.com/urfave/cli/errors.go: -------------------------------------------------------------------------------- 1 | package cli 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | "os" 7 | "strings" 8 | ) 9 | 10 | // OsExiter is the function used when the app exits. If not set defaults to os.Exit. 11 | var OsExiter = os.Exit 12 | 13 | // ErrWriter is used to write errors to the user. This can be anything 14 | // implementing the io.Writer interface and defaults to os.Stderr. 15 | var ErrWriter io.Writer = os.Stderr 16 | 17 | // MultiError is an error that wraps multiple errors. 18 | type MultiError struct { 19 | Errors []error 20 | } 21 | 22 | // NewMultiError creates a new MultiError. Pass in one or more errors. 23 | func NewMultiError(err ...error) MultiError { 24 | return MultiError{Errors: err} 25 | } 26 | 27 | // Error implents the error interface. 28 | func (m MultiError) Error() string { 29 | errs := make([]string, len(m.Errors)) 30 | for i, err := range m.Errors { 31 | errs[i] = err.Error() 32 | } 33 | 34 | return strings.Join(errs, "\n") 35 | } 36 | 37 | // ExitCoder is the interface checked by `App` and `Command` for a custom exit 38 | // code 39 | type ExitCoder interface { 40 | error 41 | ExitCode() int 42 | } 43 | 44 | // ExitError fulfills both the builtin `error` interface and `ExitCoder` 45 | type ExitError struct { 46 | exitCode int 47 | message string 48 | } 49 | 50 | // NewExitError makes a new *ExitError 51 | func NewExitError(message string, exitCode int) *ExitError { 52 | return &ExitError{ 53 | exitCode: exitCode, 54 | message: message, 55 | } 56 | } 57 | 58 | // Error returns the string message, fulfilling the interface required by 59 | // `error` 60 | func (ee *ExitError) Error() string { 61 | return ee.message 62 | } 63 | 64 | // ExitCode returns the exit code, fulfilling the interface required by 65 | // `ExitCoder` 66 | func (ee *ExitError) ExitCode() int { 67 | return ee.exitCode 68 | } 69 | 70 | // HandleExitCoder checks if the error fulfills the ExitCoder interface, and if 71 | // so prints the error to stderr (if it is non-empty) and calls OsExiter with the 72 | // given exit code. If the given error is a MultiError, then this func is 73 | // called on all members of the Errors slice. 74 | func HandleExitCoder(err error) { 75 | if err == nil { 76 | return 77 | } 78 | 79 | if exitErr, ok := err.(ExitCoder); ok { 80 | if err.Error() != "" { 81 | fmt.Fprintln(ErrWriter, err) 82 | } 83 | OsExiter(exitErr.ExitCode()) 84 | return 85 | } 86 | 87 | if multiErr, ok := err.(MultiError); ok { 88 | for _, merr := range multiErr.Errors { 89 | HandleExitCoder(merr) 90 | } 91 | return 92 | } 93 | 94 | if err.Error() != "" { 95 | fmt.Fprintln(ErrWriter, err) 96 | } 97 | OsExiter(1) 98 | } 99 | -------------------------------------------------------------------------------- /vendor/github.com/codegangsta/cli/errors.go: -------------------------------------------------------------------------------- 1 | package cli 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | "os" 7 | "strings" 8 | ) 9 | 10 | // OsExiter is the function used when the app exits. If not set defaults to os.Exit. 11 | var OsExiter = os.Exit 12 | 13 | // ErrWriter is used to write errors to the user. This can be anything 14 | // implementing the io.Writer interface and defaults to os.Stderr. 15 | var ErrWriter io.Writer = os.Stderr 16 | 17 | // MultiError is an error that wraps multiple errors. 18 | type MultiError struct { 19 | Errors []error 20 | } 21 | 22 | // NewMultiError creates a new MultiError. Pass in one or more errors. 23 | func NewMultiError(err ...error) MultiError { 24 | return MultiError{Errors: err} 25 | } 26 | 27 | // Error implents the error interface. 28 | func (m MultiError) Error() string { 29 | errs := make([]string, len(m.Errors)) 30 | for i, err := range m.Errors { 31 | errs[i] = err.Error() 32 | } 33 | 34 | return strings.Join(errs, "\n") 35 | } 36 | 37 | // ExitCoder is the interface checked by `App` and `Command` for a custom exit 38 | // code 39 | type ExitCoder interface { 40 | error 41 | ExitCode() int 42 | } 43 | 44 | // ExitError fulfills both the builtin `error` interface and `ExitCoder` 45 | type ExitError struct { 46 | exitCode int 47 | message string 48 | } 49 | 50 | // NewExitError makes a new *ExitError 51 | func NewExitError(message string, exitCode int) *ExitError { 52 | return &ExitError{ 53 | exitCode: exitCode, 54 | message: message, 55 | } 56 | } 57 | 58 | // Error returns the string message, fulfilling the interface required by 59 | // `error` 60 | func (ee *ExitError) Error() string { 61 | return ee.message 62 | } 63 | 64 | // ExitCode returns the exit code, fulfilling the interface required by 65 | // `ExitCoder` 66 | func (ee *ExitError) ExitCode() int { 67 | return ee.exitCode 68 | } 69 | 70 | // HandleExitCoder checks if the error fulfills the ExitCoder interface, and if 71 | // so prints the error to stderr (if it is non-empty) and calls OsExiter with the 72 | // given exit code. If the given error is a MultiError, then this func is 73 | // called on all members of the Errors slice. 74 | func HandleExitCoder(err error) { 75 | if err == nil { 76 | return 77 | } 78 | 79 | if exitErr, ok := err.(ExitCoder); ok { 80 | if err.Error() != "" { 81 | fmt.Fprintln(ErrWriter, err) 82 | } 83 | OsExiter(exitErr.ExitCode()) 84 | return 85 | } 86 | 87 | if multiErr, ok := err.(MultiError); ok { 88 | for _, merr := range multiErr.Errors { 89 | HandleExitCoder(merr) 90 | } 91 | return 92 | } 93 | 94 | if err.Error() != "" { 95 | fmt.Fprintln(ErrWriter, err) 96 | } 97 | OsExiter(1) 98 | } 99 | -------------------------------------------------------------------------------- /vendor/github.com/kr/text/cmd/agg/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Agg computes aggregate values over tabular text. 4 | It behaves somewhat like the SQL “GROUP BY” clause. 5 | 6 | Usage: 7 | 8 | agg [function...] 9 | 10 | It reads input from stdin as a sequence of records, one per line. 11 | It treats each line as a set of fields separated by white space. 12 | One field (the first, by default) is designated as the key. 13 | Successive lines with equal keys are grouped into a group, 14 | and agg produces one line of output for each group. 15 | (Note that only contiguous input lines can form a group. 16 | If you need to make sure that all records for a given key 17 | are grouped together, sort the input first.) 18 | 19 | For each remaining field, 20 | agg applies a function to all the values in the group, 21 | producing a single output value. 22 | The command line arguments specify which functions to use, 23 | one per field in the input table. 24 | 25 | Functions 26 | 27 | The available functions are: 28 | 29 | key group by this field (default for field 1) 30 | first value from first line of group (default for rest) 31 | last value from last line of group 32 | sample value from any line of group, uniformly at random 33 | prefix longest common string prefix 34 | join:sep concatenate strings with given sep 35 | smin lexically least string 36 | smax lexically greatest string 37 | min numerically least value 38 | max numerically greatest value 39 | sum numeric sum 40 | mean arithmetic mean 41 | count number of records (ignores input value) 42 | const:val print val, ignoring input 43 | drop omit the column entirely 44 | 45 | The numeric functions skip items that don't parse as numbers. 46 | 47 | Examples 48 | 49 | Using the following input: 50 | 51 | $ cat >input 52 | -rwx alice 100 /home/alice/bin/crdt 53 | -rw- alice 210002 /home/alice/thesis.tex 54 | -rw- bob 10051 /home/bob/expenses.tab 55 | -rwx kr 862060 /home/kr/bin/blog 56 | -rwx kr 304608 /home/kr/bin/agg 57 | 58 | Disk usage for each user, plus where that disk usage occurs 59 | (longest common prefix of filesystem paths): 60 | 61 | $ agg > 8) 68 | b[low] = byte(value & 0xFF) 69 | emitter.raw_buffer = append(emitter.raw_buffer, b[0], b[1]) 70 | } else { 71 | // Write the character using a surrogate pair (check "reader.c"). 72 | var b [4]byte 73 | value -= 0x10000 74 | b[high] = byte(0xD8 + (value >> 18)) 75 | b[low] = byte((value >> 10) & 0xFF) 76 | b[high+2] = byte(0xDC + ((value >> 8) & 0xFF)) 77 | b[low+2] = byte(value & 0xFF) 78 | emitter.raw_buffer = append(emitter.raw_buffer, b[0], b[1], b[2], b[3]) 79 | } 80 | } 81 | 82 | // Write the raw buffer. 83 | if err := emitter.write_handler(emitter, emitter.raw_buffer); err != nil { 84 | return yaml_emitter_set_writer_error(emitter, "write error: "+err.Error()) 85 | } 86 | emitter.buffer_pos = 0 87 | emitter.raw_buffer = emitter.raw_buffer[:0] 88 | return true 89 | } 90 | -------------------------------------------------------------------------------- /vendor/github.com/cheggaaa/pb/pb_x.go: -------------------------------------------------------------------------------- 1 | // +build linux darwin freebsd netbsd openbsd solaris dragonfly 2 | // +build !appengine 3 | 4 | package pb 5 | 6 | import ( 7 | "errors" 8 | "fmt" 9 | "os" 10 | "os/signal" 11 | "runtime" 12 | "sync" 13 | "syscall" 14 | "unsafe" 15 | ) 16 | 17 | const ( 18 | TIOCGWINSZ = 0x5413 19 | TIOCGWINSZ_OSX = 1074295912 20 | ) 21 | 22 | var tty *os.File 23 | 24 | var ErrPoolWasStarted = errors.New("Bar pool was started") 25 | 26 | var echoLocked bool 27 | var echoLockMutex sync.Mutex 28 | 29 | func init() { 30 | var err error 31 | tty, err = os.Open("/dev/tty") 32 | if err != nil { 33 | tty = os.Stdin 34 | } 35 | } 36 | 37 | // terminalWidth returns width of the terminal. 38 | func terminalWidth() (int, error) { 39 | w := new(window) 40 | tio := syscall.TIOCGWINSZ 41 | if runtime.GOOS == "darwin" { 42 | tio = TIOCGWINSZ_OSX 43 | } 44 | res, _, err := syscall.Syscall(sysIoctl, 45 | tty.Fd(), 46 | uintptr(tio), 47 | uintptr(unsafe.Pointer(w)), 48 | ) 49 | if int(res) == -1 { 50 | return 0, err 51 | } 52 | return int(w.Col), nil 53 | } 54 | 55 | var oldState syscall.Termios 56 | 57 | func lockEcho() (quit chan int, err error) { 58 | echoLockMutex.Lock() 59 | defer echoLockMutex.Unlock() 60 | if echoLocked { 61 | err = ErrPoolWasStarted 62 | return 63 | } 64 | echoLocked = true 65 | 66 | fd := tty.Fd() 67 | if _, _, e := syscall.Syscall6(sysIoctl, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&oldState)), 0, 0, 0); e != 0 { 68 | err = fmt.Errorf("Can't get terminal settings: %v", e) 69 | return 70 | } 71 | 72 | newState := oldState 73 | newState.Lflag &^= syscall.ECHO 74 | newState.Lflag |= syscall.ICANON | syscall.ISIG 75 | newState.Iflag |= syscall.ICRNL 76 | if _, _, e := syscall.Syscall6(sysIoctl, fd, ioctlWriteTermios, uintptr(unsafe.Pointer(&newState)), 0, 0, 0); e != 0 { 77 | err = fmt.Errorf("Can't set terminal settings: %v", e) 78 | return 79 | } 80 | quit = make(chan int, 1) 81 | go catchTerminate(quit) 82 | return 83 | } 84 | 85 | func unlockEcho() (err error) { 86 | echoLockMutex.Lock() 87 | defer echoLockMutex.Unlock() 88 | if !echoLocked { 89 | return 90 | } 91 | echoLocked = false 92 | fd := tty.Fd() 93 | if _, _, e := syscall.Syscall6(sysIoctl, fd, ioctlWriteTermios, uintptr(unsafe.Pointer(&oldState)), 0, 0, 0); e != 0 { 94 | err = fmt.Errorf("Can't set terminal settings") 95 | } 96 | return 97 | } 98 | 99 | // listen exit signals and restore terminal state 100 | func catchTerminate(quit chan int) { 101 | sig := make(chan os.Signal, 1) 102 | signal.Notify(sig, os.Interrupt, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGKILL) 103 | defer signal.Stop(sig) 104 | select { 105 | case <-quit: 106 | unlockEcho() 107 | case <-sig: 108 | unlockEcho() 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /vendor/gopkg.in/cheggaaa/pb.v1/pb_x.go: -------------------------------------------------------------------------------- 1 | // +build linux darwin freebsd netbsd openbsd solaris dragonfly 2 | // +build !appengine 3 | 4 | package pb 5 | 6 | import ( 7 | "errors" 8 | "fmt" 9 | "os" 10 | "os/signal" 11 | "runtime" 12 | "sync" 13 | "syscall" 14 | "unsafe" 15 | ) 16 | 17 | const ( 18 | TIOCGWINSZ = 0x5413 19 | TIOCGWINSZ_OSX = 1074295912 20 | ) 21 | 22 | var tty *os.File 23 | 24 | var ErrPoolWasStarted = errors.New("Bar pool was started") 25 | 26 | var echoLocked bool 27 | var echoLockMutex sync.Mutex 28 | 29 | func init() { 30 | var err error 31 | tty, err = os.Open("/dev/tty") 32 | if err != nil { 33 | tty = os.Stdin 34 | } 35 | } 36 | 37 | // terminalWidth returns width of the terminal. 38 | func terminalWidth() (int, error) { 39 | w := new(window) 40 | tio := syscall.TIOCGWINSZ 41 | if runtime.GOOS == "darwin" { 42 | tio = TIOCGWINSZ_OSX 43 | } 44 | res, _, err := syscall.Syscall(sysIoctl, 45 | tty.Fd(), 46 | uintptr(tio), 47 | uintptr(unsafe.Pointer(w)), 48 | ) 49 | if int(res) == -1 { 50 | return 0, err 51 | } 52 | return int(w.Col), nil 53 | } 54 | 55 | var oldState syscall.Termios 56 | 57 | func lockEcho() (quit chan int, err error) { 58 | echoLockMutex.Lock() 59 | defer echoLockMutex.Unlock() 60 | if echoLocked { 61 | err = ErrPoolWasStarted 62 | return 63 | } 64 | echoLocked = true 65 | 66 | fd := tty.Fd() 67 | if _, _, e := syscall.Syscall6(sysIoctl, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&oldState)), 0, 0, 0); e != 0 { 68 | err = fmt.Errorf("Can't get terminal settings: %v", e) 69 | return 70 | } 71 | 72 | newState := oldState 73 | newState.Lflag &^= syscall.ECHO 74 | newState.Lflag |= syscall.ICANON | syscall.ISIG 75 | newState.Iflag |= syscall.ICRNL 76 | if _, _, e := syscall.Syscall6(sysIoctl, fd, ioctlWriteTermios, uintptr(unsafe.Pointer(&newState)), 0, 0, 0); e != 0 { 77 | err = fmt.Errorf("Can't set terminal settings: %v", e) 78 | return 79 | } 80 | quit = make(chan int, 1) 81 | go catchTerminate(quit) 82 | return 83 | } 84 | 85 | func unlockEcho() (err error) { 86 | echoLockMutex.Lock() 87 | defer echoLockMutex.Unlock() 88 | if !echoLocked { 89 | return 90 | } 91 | echoLocked = false 92 | fd := tty.Fd() 93 | if _, _, e := syscall.Syscall6(sysIoctl, fd, ioctlWriteTermios, uintptr(unsafe.Pointer(&oldState)), 0, 0, 0); e != 0 { 94 | err = fmt.Errorf("Can't set terminal settings") 95 | } 96 | return 97 | } 98 | 99 | // listen exit signals and restore terminal state 100 | func catchTerminate(quit chan int) { 101 | sig := make(chan os.Signal, 1) 102 | signal.Notify(sig, os.Interrupt, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGKILL) 103 | defer signal.Stop(sig) 104 | select { 105 | case <-quit: 106 | unlockEcho() 107 | case <-sig: 108 | unlockEcho() 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /cmd/templates.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "path/filepath" 7 | 8 | json "github.com/dutchcoders/elastico/json" 9 | 10 | "github.com/codegangsta/cli" 11 | ) 12 | 13 | var ( 14 | _ = registerTemplate("template:create", `Template created. 15 | `) 16 | _ = registerTemplate("template:list", `== Templates 17 | Name Indexes Order 18 | ===================================== ========================= ============== 19 | {{range $name, $template := . }} 20 | {{- $name | yellow | printf "%-46s" }} {{ $template.template | printf "%-20s" }}{{ $template.order| printf "%20.0f" }} 21 | {{ end}}`) 22 | _ = registerTemplate("template:delete", `Template deleted. 23 | `) 24 | ) 25 | 26 | var templateCmds = []cli.Command{ 27 | cli.Command{ 28 | Name: "template:delete", 29 | Usage: "Delete template", 30 | Description: ``, 31 | Action: run(runTemplateDelete), 32 | Flags: []cli.Flag{ 33 | TemplateRequiredFlag, 34 | }, 35 | }, 36 | cli.Command{ 37 | Name: "template:list", 38 | Usage: "List templates", 39 | Description: ``, 40 | Action: run(runTemplateList), 41 | Flags: []cli.Flag{}, 42 | }, 43 | cli.Command{ 44 | Name: "template:create", 45 | Usage: "Create template", 46 | Description: ``, 47 | Action: run(runTemplateCreate), 48 | Flags: []cli.Flag{ 49 | TemplateRequiredFlag, 50 | }, 51 | }, 52 | } 53 | 54 | func runTemplateDelete(c *cli.Context) (json.M, error) { 55 | template := c.String("template") 56 | 57 | path := filepath.Join("_template", template) 58 | 59 | req, err := e.NewRequest("DELETE", path, nil) 60 | if err != nil { 61 | return nil, err 62 | } 63 | 64 | var resp json.M 65 | if err := e.Do(req, &resp); err != nil { 66 | return nil, err 67 | } 68 | 69 | return resp, nil 70 | } 71 | 72 | func runTemplateList(c *cli.Context) (json.M, error) { 73 | path := filepath.Join("_template") 74 | 75 | req, err := e.NewRequest("GET", path, nil) 76 | if err != nil { 77 | return nil, err 78 | } 79 | 80 | var resp json.M 81 | if err := e.Do(req, &resp); err != nil { 82 | return nil, err 83 | } 84 | 85 | return resp, nil 86 | } 87 | func runTemplateCreate(c *cli.Context) (json.M, error) { 88 | template := c.String("template") 89 | 90 | path := filepath.Join("_template", template) 91 | 92 | var body interface{} 93 | if fi, err := os.Stdin.Stat(); err != nil { 94 | return nil, fmt.Errorf("No stdin body template") 95 | } else if fi.Mode()&os.ModeNamedPipe > 0 { 96 | body = os.Stdin 97 | } 98 | 99 | req, err := e.NewRequest("PUT", path, body) 100 | if err != nil { 101 | return nil, err 102 | } 103 | 104 | var resp json.M 105 | if err := e.Do(req, &resp); err != nil { 106 | return nil, err 107 | } 108 | 109 | return resp, nil 110 | } 111 | -------------------------------------------------------------------------------- /vendor/github.com/BurntSushi/toml/type_check.go: -------------------------------------------------------------------------------- 1 | package toml 2 | 3 | // tomlType represents any Go type that corresponds to a TOML type. 4 | // While the first draft of the TOML spec has a simplistic type system that 5 | // probably doesn't need this level of sophistication, we seem to be militating 6 | // toward adding real composite types. 7 | type tomlType interface { 8 | typeString() string 9 | } 10 | 11 | // typeEqual accepts any two types and returns true if they are equal. 12 | func typeEqual(t1, t2 tomlType) bool { 13 | if t1 == nil || t2 == nil { 14 | return false 15 | } 16 | return t1.typeString() == t2.typeString() 17 | } 18 | 19 | func typeIsHash(t tomlType) bool { 20 | return typeEqual(t, tomlHash) || typeEqual(t, tomlArrayHash) 21 | } 22 | 23 | type tomlBaseType string 24 | 25 | func (btype tomlBaseType) typeString() string { 26 | return string(btype) 27 | } 28 | 29 | func (btype tomlBaseType) String() string { 30 | return btype.typeString() 31 | } 32 | 33 | var ( 34 | tomlInteger tomlBaseType = "Integer" 35 | tomlFloat tomlBaseType = "Float" 36 | tomlDatetime tomlBaseType = "Datetime" 37 | tomlString tomlBaseType = "String" 38 | tomlBool tomlBaseType = "Bool" 39 | tomlArray tomlBaseType = "Array" 40 | tomlHash tomlBaseType = "Hash" 41 | tomlArrayHash tomlBaseType = "ArrayHash" 42 | ) 43 | 44 | // typeOfPrimitive returns a tomlType of any primitive value in TOML. 45 | // Primitive values are: Integer, Float, Datetime, String and Bool. 46 | // 47 | // Passing a lexer item other than the following will cause a BUG message 48 | // to occur: itemString, itemBool, itemInteger, itemFloat, itemDatetime. 49 | func (p *parser) typeOfPrimitive(lexItem item) tomlType { 50 | switch lexItem.typ { 51 | case itemInteger: 52 | return tomlInteger 53 | case itemFloat: 54 | return tomlFloat 55 | case itemDatetime: 56 | return tomlDatetime 57 | case itemString: 58 | return tomlString 59 | case itemMultilineString: 60 | return tomlString 61 | case itemRawString: 62 | return tomlString 63 | case itemRawMultilineString: 64 | return tomlString 65 | case itemBool: 66 | return tomlBool 67 | } 68 | p.bug("Cannot infer primitive type of lex item '%s'.", lexItem) 69 | panic("unreachable") 70 | } 71 | 72 | // typeOfArray returns a tomlType for an array given a list of types of its 73 | // values. 74 | // 75 | // In the current spec, if an array is homogeneous, then its type is always 76 | // "Array". If the array is not homogeneous, an error is generated. 77 | func (p *parser) typeOfArray(types []tomlType) tomlType { 78 | // Empty arrays are cool. 79 | if len(types) == 0 { 80 | return tomlArray 81 | } 82 | 83 | theType := types[0] 84 | for _, t := range types[1:] { 85 | if !typeEqual(theType, t) { 86 | p.panicf("Array contains values of type '%s' and '%s', but "+ 87 | "arrays must be homogeneous.", theType, t) 88 | } 89 | } 90 | return tomlArray 91 | } 92 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | // Package unix contains an interface to the low-level operating system 8 | // primitives. OS details vary depending on the underlying system, and 9 | // by default, godoc will display OS-specific documentation for the current 10 | // system. If you want godoc to display OS documentation for another 11 | // system, set $GOOS and $GOARCH to the desired system. For example, if 12 | // you want to view documentation for freebsd/arm on linux/amd64, set $GOOS 13 | // to freebsd and $GOARCH to arm. 14 | // The primary use of this package is inside other packages that provide a more 15 | // portable interface to the system, such as "os", "time" and "net". Use 16 | // those packages rather than this one if you can. 17 | // For details of the functions and data types in this package consult 18 | // the manuals for the appropriate operating system. 19 | // These calls return err == nil to indicate success; otherwise 20 | // err represents an operating system error describing the failure and 21 | // holds a value of type syscall.Errno. 22 | package unix // import "golang.org/x/sys/unix" 23 | 24 | import "unsafe" 25 | 26 | // ByteSliceFromString returns a NUL-terminated slice of bytes 27 | // containing the text of s. If s contains a NUL byte at any 28 | // location, it returns (nil, EINVAL). 29 | func ByteSliceFromString(s string) ([]byte, error) { 30 | for i := 0; i < len(s); i++ { 31 | if s[i] == 0 { 32 | return nil, EINVAL 33 | } 34 | } 35 | a := make([]byte, len(s)+1) 36 | copy(a, s) 37 | return a, nil 38 | } 39 | 40 | // BytePtrFromString returns a pointer to a NUL-terminated array of 41 | // bytes containing the text of s. If s contains a NUL byte at any 42 | // location, it returns (nil, EINVAL). 43 | func BytePtrFromString(s string) (*byte, error) { 44 | a, err := ByteSliceFromString(s) 45 | if err != nil { 46 | return nil, err 47 | } 48 | return &a[0], nil 49 | } 50 | 51 | // Single-word zero for use when we need a valid pointer to 0 bytes. 52 | // See mkunix.pl. 53 | var _zero uintptr 54 | 55 | func (ts *Timespec) Unix() (sec int64, nsec int64) { 56 | return int64(ts.Sec), int64(ts.Nsec) 57 | } 58 | 59 | func (tv *Timeval) Unix() (sec int64, nsec int64) { 60 | return int64(tv.Sec), int64(tv.Usec) * 1000 61 | } 62 | 63 | func (ts *Timespec) Nano() int64 { 64 | return int64(ts.Sec)*1e9 + int64(ts.Nsec) 65 | } 66 | 67 | func (tv *Timeval) Nano() int64 { 68 | return int64(tv.Sec)*1e9 + int64(tv.Usec)*1000 69 | } 70 | 71 | func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 72 | 73 | // use is a no-op, but the compiler cannot see that it is. 74 | // Calling use(p) ensures that p is kept live until that point. 75 | //go:noescape 76 | func use(p unsafe.Pointer) 77 | -------------------------------------------------------------------------------- /vendor/gopkg.in/yaml.v2/sorter.go: -------------------------------------------------------------------------------- 1 | package yaml 2 | 3 | import ( 4 | "reflect" 5 | "unicode" 6 | ) 7 | 8 | type keyList []reflect.Value 9 | 10 | func (l keyList) Len() int { return len(l) } 11 | func (l keyList) Swap(i, j int) { l[i], l[j] = l[j], l[i] } 12 | func (l keyList) Less(i, j int) bool { 13 | a := l[i] 14 | b := l[j] 15 | ak := a.Kind() 16 | bk := b.Kind() 17 | for (ak == reflect.Interface || ak == reflect.Ptr) && !a.IsNil() { 18 | a = a.Elem() 19 | ak = a.Kind() 20 | } 21 | for (bk == reflect.Interface || bk == reflect.Ptr) && !b.IsNil() { 22 | b = b.Elem() 23 | bk = b.Kind() 24 | } 25 | af, aok := keyFloat(a) 26 | bf, bok := keyFloat(b) 27 | if aok && bok { 28 | if af != bf { 29 | return af < bf 30 | } 31 | if ak != bk { 32 | return ak < bk 33 | } 34 | return numLess(a, b) 35 | } 36 | if ak != reflect.String || bk != reflect.String { 37 | return ak < bk 38 | } 39 | ar, br := []rune(a.String()), []rune(b.String()) 40 | for i := 0; i < len(ar) && i < len(br); i++ { 41 | if ar[i] == br[i] { 42 | continue 43 | } 44 | al := unicode.IsLetter(ar[i]) 45 | bl := unicode.IsLetter(br[i]) 46 | if al && bl { 47 | return ar[i] < br[i] 48 | } 49 | if al || bl { 50 | return bl 51 | } 52 | var ai, bi int 53 | var an, bn int64 54 | for ai = i; ai < len(ar) && unicode.IsDigit(ar[ai]); ai++ { 55 | an = an*10 + int64(ar[ai]-'0') 56 | } 57 | for bi = i; bi < len(br) && unicode.IsDigit(br[bi]); bi++ { 58 | bn = bn*10 + int64(br[bi]-'0') 59 | } 60 | if an != bn { 61 | return an < bn 62 | } 63 | if ai != bi { 64 | return ai < bi 65 | } 66 | return ar[i] < br[i] 67 | } 68 | return len(ar) < len(br) 69 | } 70 | 71 | // keyFloat returns a float value for v if it is a number/bool 72 | // and whether it is a number/bool or not. 73 | func keyFloat(v reflect.Value) (f float64, ok bool) { 74 | switch v.Kind() { 75 | case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: 76 | return float64(v.Int()), true 77 | case reflect.Float32, reflect.Float64: 78 | return v.Float(), true 79 | case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: 80 | return float64(v.Uint()), true 81 | case reflect.Bool: 82 | if v.Bool() { 83 | return 1, true 84 | } 85 | return 0, true 86 | } 87 | return 0, false 88 | } 89 | 90 | // numLess returns whether a < b. 91 | // a and b must necessarily have the same kind. 92 | func numLess(a, b reflect.Value) bool { 93 | switch a.Kind() { 94 | case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: 95 | return a.Int() < b.Int() 96 | case reflect.Float32, reflect.Float64: 97 | return a.Float() < b.Float() 98 | case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: 99 | return a.Uint() < b.Uint() 100 | case reflect.Bool: 101 | return !a.Bool() && b.Bool() 102 | } 103 | panic("not a number") 104 | } 105 | -------------------------------------------------------------------------------- /vendor/github.com/dustin/go-humanize/si.go: -------------------------------------------------------------------------------- 1 | package humanize 2 | 3 | import ( 4 | "errors" 5 | "math" 6 | "regexp" 7 | "strconv" 8 | ) 9 | 10 | var siPrefixTable = map[float64]string{ 11 | -24: "y", // yocto 12 | -21: "z", // zepto 13 | -18: "a", // atto 14 | -15: "f", // femto 15 | -12: "p", // pico 16 | -9: "n", // nano 17 | -6: "µ", // micro 18 | -3: "m", // milli 19 | 0: "", 20 | 3: "k", // kilo 21 | 6: "M", // mega 22 | 9: "G", // giga 23 | 12: "T", // tera 24 | 15: "P", // peta 25 | 18: "E", // exa 26 | 21: "Z", // zetta 27 | 24: "Y", // yotta 28 | } 29 | 30 | var revSIPrefixTable = revfmap(siPrefixTable) 31 | 32 | // revfmap reverses the map and precomputes the power multiplier 33 | func revfmap(in map[float64]string) map[string]float64 { 34 | rv := map[string]float64{} 35 | for k, v := range in { 36 | rv[v] = math.Pow(10, k) 37 | } 38 | return rv 39 | } 40 | 41 | var riParseRegex *regexp.Regexp 42 | 43 | func init() { 44 | ri := `^([\-0-9.]+)\s?([` 45 | for _, v := range siPrefixTable { 46 | ri += v 47 | } 48 | ri += `]?)(.*)` 49 | 50 | riParseRegex = regexp.MustCompile(ri) 51 | } 52 | 53 | // ComputeSI finds the most appropriate SI prefix for the given number 54 | // and returns the prefix along with the value adjusted to be within 55 | // that prefix. 56 | // 57 | // See also: SI, ParseSI. 58 | // 59 | // e.g. ComputeSI(2.2345e-12) -> (2.2345, "p") 60 | func ComputeSI(input float64) (float64, string) { 61 | if input == 0 { 62 | return 0, "" 63 | } 64 | mag := math.Abs(input) 65 | exponent := math.Floor(logn(mag, 10)) 66 | exponent = math.Floor(exponent/3) * 3 67 | 68 | value := mag / math.Pow(10, exponent) 69 | 70 | // Handle special case where value is exactly 1000.0 71 | // Should return 1M instead of 1000k 72 | if value == 1000.0 { 73 | exponent += 3 74 | value = mag / math.Pow(10, exponent) 75 | } 76 | 77 | value = math.Copysign(value, input) 78 | 79 | prefix := siPrefixTable[exponent] 80 | return value, prefix 81 | } 82 | 83 | // SI returns a string with default formatting. 84 | // 85 | // SI uses Ftoa to format float value, removing trailing zeros. 86 | // 87 | // See also: ComputeSI, ParseSI. 88 | // 89 | // e.g. SI(1000000, B) -> 1MB 90 | // e.g. SI(2.2345e-12, "F") -> 2.2345pF 91 | func SI(input float64, unit string) string { 92 | value, prefix := ComputeSI(input) 93 | return Ftoa(value) + " " + prefix + unit 94 | } 95 | 96 | var errInvalid = errors.New("invalid input") 97 | 98 | // ParseSI parses an SI string back into the number and unit. 99 | // 100 | // See also: SI, ComputeSI. 101 | // 102 | // e.g. ParseSI(2.2345pF) -> (2.2345e-12, "F", nil) 103 | func ParseSI(input string) (float64, string, error) { 104 | found := riParseRegex.FindStringSubmatch(input) 105 | if len(found) != 4 { 106 | return 0, "", errInvalid 107 | } 108 | mag := revSIPrefixTable[found[2]] 109 | unit := found[3] 110 | 111 | base, err := strconv.ParseFloat(found[1], 64) 112 | return base * mag, unit, err 113 | } 114 | -------------------------------------------------------------------------------- /vendor/github.com/op/go-logging/log_nix.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | 3 | // Copyright 2013, Örjan Persson. All rights reserved. 4 | // Use of this source code is governed by a BSD-style 5 | // license that can be found in the LICENSE file. 6 | 7 | package logging 8 | 9 | import ( 10 | "bytes" 11 | "fmt" 12 | "io" 13 | "log" 14 | ) 15 | 16 | type color int 17 | 18 | const ( 19 | ColorBlack = iota + 30 20 | ColorRed 21 | ColorGreen 22 | ColorYellow 23 | ColorBlue 24 | ColorMagenta 25 | ColorCyan 26 | ColorWhite 27 | ) 28 | 29 | var ( 30 | colors = []string{ 31 | CRITICAL: ColorSeq(ColorMagenta), 32 | ERROR: ColorSeq(ColorRed), 33 | WARNING: ColorSeq(ColorYellow), 34 | NOTICE: ColorSeq(ColorGreen), 35 | DEBUG: ColorSeq(ColorCyan), 36 | } 37 | boldcolors = []string{ 38 | CRITICAL: ColorSeqBold(ColorMagenta), 39 | ERROR: ColorSeqBold(ColorRed), 40 | WARNING: ColorSeqBold(ColorYellow), 41 | NOTICE: ColorSeqBold(ColorGreen), 42 | DEBUG: ColorSeqBold(ColorCyan), 43 | } 44 | ) 45 | 46 | // LogBackend utilizes the standard log module. 47 | type LogBackend struct { 48 | Logger *log.Logger 49 | Color bool 50 | ColorConfig []string 51 | } 52 | 53 | // NewLogBackend creates a new LogBackend. 54 | func NewLogBackend(out io.Writer, prefix string, flag int) *LogBackend { 55 | return &LogBackend{Logger: log.New(out, prefix, flag)} 56 | } 57 | 58 | // Log implements the Backend interface. 59 | func (b *LogBackend) Log(level Level, calldepth int, rec *Record) error { 60 | if b.Color { 61 | col := colors[level] 62 | if len(b.ColorConfig) > int(level) && b.ColorConfig[level] != "" { 63 | col = b.ColorConfig[level] 64 | } 65 | 66 | buf := &bytes.Buffer{} 67 | buf.Write([]byte(col)) 68 | buf.Write([]byte(rec.Formatted(calldepth + 1))) 69 | buf.Write([]byte("\033[0m")) 70 | // For some reason, the Go logger arbitrarily decided "2" was the correct 71 | // call depth... 72 | return b.Logger.Output(calldepth+2, buf.String()) 73 | } 74 | 75 | return b.Logger.Output(calldepth+2, rec.Formatted(calldepth+1)) 76 | } 77 | 78 | // ConvertColors takes a list of ints representing colors for log levels and 79 | // converts them into strings for ANSI color formatting 80 | func ConvertColors(colors []int, bold bool) []string { 81 | converted := []string{} 82 | for _, i := range colors { 83 | if bold { 84 | converted = append(converted, ColorSeqBold(color(i))) 85 | } else { 86 | converted = append(converted, ColorSeq(color(i))) 87 | } 88 | } 89 | 90 | return converted 91 | } 92 | 93 | func ColorSeq(color color) string { 94 | return fmt.Sprintf("\033[%dm", int(color)) 95 | } 96 | 97 | func ColorSeqBold(color color) string { 98 | return fmt.Sprintf("\033[%d;1m", int(color)) 99 | } 100 | 101 | func doFmtVerbLevelColor(layout string, level Level, output io.Writer) { 102 | if layout == "bold" { 103 | output.Write([]byte(boldcolors[level])) 104 | } else if layout == "reset" { 105 | output.Write([]byte("\033[0m")) 106 | } else { 107 | output.Write([]byte(colors[level])) 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /json/tagkey_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package json 6 | 7 | import ( 8 | "testing" 9 | ) 10 | 11 | type basicLatin2xTag struct { 12 | V string `json:"$%-/"` 13 | } 14 | 15 | type basicLatin3xTag struct { 16 | V string `json:"0123456789"` 17 | } 18 | 19 | type basicLatin4xTag struct { 20 | V string `json:"ABCDEFGHIJKLMO"` 21 | } 22 | 23 | type basicLatin5xTag struct { 24 | V string `json:"PQRSTUVWXYZ_"` 25 | } 26 | 27 | type basicLatin6xTag struct { 28 | V string `json:"abcdefghijklmno"` 29 | } 30 | 31 | type basicLatin7xTag struct { 32 | V string `json:"pqrstuvwxyz"` 33 | } 34 | 35 | type miscPlaneTag struct { 36 | V string `json:"色は匂へど"` 37 | } 38 | 39 | type percentSlashTag struct { 40 | V string `json:"text/html%"` // https://golang.org/issue/2718 41 | } 42 | 43 | type punctuationTag struct { 44 | V string `json:"!#$%&()*+-./:<=>?@[]^_{|}~"` // https://golang.org/issue/3546 45 | } 46 | 47 | type emptyTag struct { 48 | W string 49 | } 50 | 51 | type misnamedTag struct { 52 | X string `jsom:"Misnamed"` 53 | } 54 | 55 | type badFormatTag struct { 56 | Y string `:"BadFormat"` 57 | } 58 | 59 | type badCodeTag struct { 60 | Z string `json:" !\"#&'()*+,."` 61 | } 62 | 63 | type spaceTag struct { 64 | Q string `json:"With space"` 65 | } 66 | 67 | type unicodeTag struct { 68 | W string `json:"Ελλάδα"` 69 | } 70 | 71 | var structTagObjectKeyTests = []struct { 72 | raw interface{} 73 | value string 74 | key string 75 | }{ 76 | {basicLatin2xTag{"2x"}, "2x", "$%-/"}, 77 | {basicLatin3xTag{"3x"}, "3x", "0123456789"}, 78 | {basicLatin4xTag{"4x"}, "4x", "ABCDEFGHIJKLMO"}, 79 | {basicLatin5xTag{"5x"}, "5x", "PQRSTUVWXYZ_"}, 80 | {basicLatin6xTag{"6x"}, "6x", "abcdefghijklmno"}, 81 | {basicLatin7xTag{"7x"}, "7x", "pqrstuvwxyz"}, 82 | {miscPlaneTag{"いろはにほへと"}, "いろはにほへと", "色は匂へど"}, 83 | {emptyTag{"Pour Moi"}, "Pour Moi", "W"}, 84 | {misnamedTag{"Animal Kingdom"}, "Animal Kingdom", "X"}, 85 | {badFormatTag{"Orfevre"}, "Orfevre", "Y"}, 86 | {badCodeTag{"Reliable Man"}, "Reliable Man", "Z"}, 87 | {percentSlashTag{"brut"}, "brut", "text/html%"}, 88 | {punctuationTag{"Union Rags"}, "Union Rags", "!#$%&()*+-./:<=>?@[]^_{|}~"}, 89 | {spaceTag{"Perreddu"}, "Perreddu", "With space"}, 90 | {unicodeTag{"Loukanikos"}, "Loukanikos", "Ελλάδα"}, 91 | } 92 | 93 | func TestStructTagObjectKey(t *testing.T) { 94 | for _, tt := range structTagObjectKeyTests { 95 | b, err := Marshal(tt.raw) 96 | if err != nil { 97 | t.Fatalf("Marshal(%#q) failed: %v", tt.raw, err) 98 | } 99 | var f interface{} 100 | err = Unmarshal(b, &f) 101 | if err != nil { 102 | t.Fatalf("Unmarshal(%#q) failed: %v", b, err) 103 | } 104 | for i, v := range f.(map[string]interface{}) { 105 | switch i { 106 | case tt.key: 107 | if s, ok := v.(string); !ok || s != tt.value { 108 | t.Fatalf("Unexpected value: %#q, want %v", s, tt.value) 109 | } 110 | default: 111 | t.Fatalf("Unexpected key: %#q, from %#q", i, b) 112 | } 113 | } 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /vendor/github.com/dustin/go-humanize/bytes.go: -------------------------------------------------------------------------------- 1 | package humanize 2 | 3 | import ( 4 | "fmt" 5 | "math" 6 | "strconv" 7 | "strings" 8 | "unicode" 9 | ) 10 | 11 | // IEC Sizes. 12 | // kibis of bits 13 | const ( 14 | Byte = 1 << (iota * 10) 15 | KiByte 16 | MiByte 17 | GiByte 18 | TiByte 19 | PiByte 20 | EiByte 21 | ) 22 | 23 | // SI Sizes. 24 | const ( 25 | IByte = 1 26 | KByte = IByte * 1000 27 | MByte = KByte * 1000 28 | GByte = MByte * 1000 29 | TByte = GByte * 1000 30 | PByte = TByte * 1000 31 | EByte = PByte * 1000 32 | ) 33 | 34 | var bytesSizeTable = map[string]uint64{ 35 | "b": Byte, 36 | "kib": KiByte, 37 | "kb": KByte, 38 | "mib": MiByte, 39 | "mb": MByte, 40 | "gib": GiByte, 41 | "gb": GByte, 42 | "tib": TiByte, 43 | "tb": TByte, 44 | "pib": PiByte, 45 | "pb": PByte, 46 | "eib": EiByte, 47 | "eb": EByte, 48 | // Without suffix 49 | "": Byte, 50 | "ki": KiByte, 51 | "k": KByte, 52 | "mi": MiByte, 53 | "m": MByte, 54 | "gi": GiByte, 55 | "g": GByte, 56 | "ti": TiByte, 57 | "t": TByte, 58 | "pi": PiByte, 59 | "p": PByte, 60 | "ei": EiByte, 61 | "e": EByte, 62 | } 63 | 64 | func logn(n, b float64) float64 { 65 | return math.Log(n) / math.Log(b) 66 | } 67 | 68 | func humanateBytes(s uint64, base float64, sizes []string) string { 69 | if s < 10 { 70 | return fmt.Sprintf("%d B", s) 71 | } 72 | e := math.Floor(logn(float64(s), base)) 73 | suffix := sizes[int(e)] 74 | val := math.Floor(float64(s)/math.Pow(base, e)*10+0.5) / 10 75 | f := "%.0f %s" 76 | if val < 10 { 77 | f = "%.1f %s" 78 | } 79 | 80 | return fmt.Sprintf(f, val, suffix) 81 | } 82 | 83 | // Bytes produces a human readable representation of an SI size. 84 | // 85 | // See also: ParseBytes. 86 | // 87 | // Bytes(82854982) -> 83MB 88 | func Bytes(s uint64) string { 89 | sizes := []string{"B", "kB", "MB", "GB", "TB", "PB", "EB"} 90 | return humanateBytes(s, 1000, sizes) 91 | } 92 | 93 | // IBytes produces a human readable representation of an IEC size. 94 | // 95 | // See also: ParseBytes. 96 | // 97 | // IBytes(82854982) -> 79MiB 98 | func IBytes(s uint64) string { 99 | sizes := []string{"B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB"} 100 | return humanateBytes(s, 1024, sizes) 101 | } 102 | 103 | // ParseBytes parses a string representation of bytes into the number 104 | // of bytes it represents. 105 | // 106 | // See Also: Bytes, IBytes. 107 | // 108 | // ParseBytes("42MB") -> 42000000, nil 109 | // ParseBytes("42mib") -> 44040192, nil 110 | func ParseBytes(s string) (uint64, error) { 111 | lastDigit := 0 112 | for _, r := range s { 113 | if !(unicode.IsDigit(r) || r == '.') { 114 | break 115 | } 116 | lastDigit++ 117 | } 118 | 119 | f, err := strconv.ParseFloat(s[:lastDigit], 64) 120 | if err != nil { 121 | return 0, err 122 | } 123 | 124 | extra := strings.ToLower(strings.TrimSpace(s[lastDigit:])) 125 | if m, ok := bytesSizeTable[extra]; ok { 126 | f *= float64(m) 127 | if f >= math.MaxUint64 { 128 | return 0, fmt.Errorf("too large: %v", s) 129 | } 130 | return uint64(f), nil 131 | } 132 | 133 | return 0, fmt.Errorf("unhandled size name: %v", extra) 134 | } 135 | -------------------------------------------------------------------------------- /cmd/search.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "path/filepath" 7 | 8 | json "github.com/dutchcoders/elastico/json" 9 | 10 | "github.com/codegangsta/cli" 11 | ) 12 | 13 | var ( 14 | _ = registerTemplate("search", `== Search 15 | Took: {{ .took | time}} 16 | Total: {{ .hits.total}} 17 | Max score: {{ .hits.max_score}} 18 | 19 | {{ if gt (.hits.hits | len) 0 -}} 20 | == Hits 21 | Index Type ID Score 22 | ================================== ====================== ======================================== ==================== 23 | {{range $hit := .hits.hits -}} 24 | {{- $hit._index | yellow | printf "%-44s" }}{{ $hit._type | printf "%-22s" }} {{ $hit._id | printf "%-40s" }} {{ $hit._score | printf "%20.2f" }} 25 | {{range $name, $highlights := $hit.highlight -}} 26 | {{ $name | green }}: {{ range $highlight := $highlights -}} {{ $highlight | trim }} {{end }} 27 | {{end -}} 28 | {{end -}} 29 | {{- else -}} 30 | {{end -}} 31 | {{ if (has . "aggregations") }} 32 | {{ if gt (.aggregations | len) 0 }} 33 | == Aggregations 34 | {{range $name, $agg := .aggregations -}} 35 | {{- $hasBuckets := (has $agg "buckets") -}} 36 | {{ if $hasBuckets -}} 37 | + {{ $name }} 38 | {{range $bucket := $agg.buckets -}} 39 | {{ " " }}{{ $bucket.key }}: {{ $bucket.doc_count }} 40 | {{- end }} 41 | other: {{ $agg.sum_other_doc_count }} 42 | {{- else -}} 43 | + {{ $name }}: {{ $agg.value -}} 44 | {{end }} 45 | {{ end }} 46 | {{end -}} 47 | {{end -}} 48 | `) 49 | ) 50 | 51 | var searchCmds = []cli.Command{ 52 | cli.Command{ 53 | Name: "search", 54 | Usage: "Search through index (and type)", 55 | Description: ``, 56 | Action: run(runSearch), 57 | Flags: []cli.Flag{ 58 | IndexFlag, 59 | TypeFlag, 60 | FieldFlag, 61 | cli.IntFlag{ 62 | Name: "size", 63 | Value: 10, 64 | }, 65 | cli.BoolFlag{ 66 | Name: "disable-highlight", 67 | }, 68 | }, 69 | }, 70 | } 71 | 72 | // highlight 73 | func runSearch(c *cli.Context) (json.M, error) { 74 | path := c.String("index") 75 | path = filepath.Join(path, c.String("type")) 76 | path = filepath.Join(path, fmt.Sprintf("_search?size=%d", c.Int("size"))) 77 | 78 | var body interface{} 79 | if len(c.Args()) > 0 { 80 | body = json.M{ 81 | "query": json.M{ 82 | "simple_query_string": json.M{ 83 | "query": c.Args()[0], 84 | }, 85 | }, 86 | } 87 | 88 | if !c.Bool("disable-highlight") { 89 | body.(json.M).Set("highlight", json.M{ 90 | "require_field_match": false, 91 | "pre_tags": []string{"\x1b[93m"}, 92 | "post_tags": []string{"\x1b[0m"}, 93 | "tag_schema": "styled", 94 | "fields": json.M{ 95 | "*": json.M{}, 96 | }, 97 | }) 98 | } 99 | } else if fi, err := os.Stdin.Stat(); err != nil { 100 | } else if fi.Mode()&os.ModeNamedPipe > 0 { 101 | body = os.Stdin 102 | } 103 | 104 | req, err := e.NewRequest("GET", path, body) 105 | if err != nil { 106 | return nil, err 107 | } 108 | 109 | var resp json.M 110 | if err := e.Do(req, &resp); err != nil { 111 | return nil, err 112 | } 113 | 114 | return resp, nil 115 | } 116 | --------------------------------------------------------------------------------