dep prune
This commit is contained in:
parent
65441fa5b3
commit
3a2d24baca
1564 changed files with 0 additions and 638818 deletions
43
vendor/github.com/olekukonko/tablewriter/csv2table/README.md
generated
vendored
43
vendor/github.com/olekukonko/tablewriter/csv2table/README.md
generated
vendored
|
|
@ -1,43 +0,0 @@
|
|||
ASCII Table Writer Tool
|
||||
=========
|
||||
|
||||
Generate ASCII table on the fly via command line ... Installation is simple as
|
||||
|
||||
#### Get Tool
|
||||
|
||||
go get github.com/olekukonko/tablewriter/csv2table
|
||||
|
||||
#### Install Tool
|
||||
|
||||
go install github.com/olekukonko/tablewriter/csv2table
|
||||
|
||||
|
||||
#### Usage
|
||||
|
||||
csv2table -f test.csv
|
||||
|
||||
#### Support for Piping
|
||||
|
||||
cat test.csv | csv2table -p=true
|
||||
|
||||
#### Output
|
||||
|
||||
```
|
||||
+------------+-----------+---------+
|
||||
| FIRST NAME | LAST NAME | SSN |
|
||||
+------------+-----------+---------+
|
||||
| John | Barry | 123456 |
|
||||
| Kathy | Smith | 687987 |
|
||||
| Bob | McCornick | 3979870 |
|
||||
+------------+-----------+---------+
|
||||
```
|
||||
|
||||
#### Another Piping with Header set to `false`
|
||||
|
||||
echo dance,with,me | csv2table -p=true -h=false
|
||||
|
||||
#### Output
|
||||
|
||||
+-------+------+-----+
|
||||
| dance | with | me |
|
||||
+-------+------+-----+
|
||||
85
vendor/github.com/olekukonko/tablewriter/csv2table/csv2table.go
generated
vendored
85
vendor/github.com/olekukonko/tablewriter/csv2table/csv2table.go
generated
vendored
|
|
@ -1,85 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"encoding/csv"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"unicode/utf8"
|
||||
|
||||
"github.com/olekukonko/tablewriter"
|
||||
)
|
||||
|
||||
var (
|
||||
fileName = flag.String("f", "", "Set file with eg. sample.csv")
|
||||
delimiter = flag.String("d", ",", "Set CSV File delimiter eg. ,|;|\t ")
|
||||
header = flag.Bool("h", true, "Set header options eg. true|false ")
|
||||
align = flag.String("a", "none", "Set aligmement with eg. none|left|right|center")
|
||||
pipe = flag.Bool("p", false, "Suport for Piping from STDIN")
|
||||
border = flag.Bool("b", true, "Enable / disable table border")
|
||||
)
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
fmt.Println()
|
||||
if *pipe || hasArg("-p") {
|
||||
process(os.Stdin)
|
||||
} else {
|
||||
if *fileName == "" {
|
||||
fmt.Fprintf(os.Stderr, "Usage of %s:\n", os.Args[0])
|
||||
flag.PrintDefaults()
|
||||
fmt.Println()
|
||||
os.Exit(1)
|
||||
}
|
||||
processFile()
|
||||
}
|
||||
fmt.Println()
|
||||
}
|
||||
|
||||
func hasArg(name string) bool {
|
||||
for _, v := range os.Args {
|
||||
if name == v {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
func processFile() {
|
||||
r, err := os.Open(*fileName)
|
||||
if err != nil {
|
||||
exit(err)
|
||||
}
|
||||
defer r.Close()
|
||||
process(r)
|
||||
}
|
||||
func process(r io.Reader) {
|
||||
csvReader := csv.NewReader(r)
|
||||
rune, size := utf8.DecodeRuneInString(*delimiter)
|
||||
if size == 0 {
|
||||
rune = ','
|
||||
}
|
||||
csvReader.Comma = rune
|
||||
|
||||
table, err := tablewriter.NewCSVReader(os.Stdout, csvReader, *header)
|
||||
|
||||
if err != nil {
|
||||
exit(err)
|
||||
}
|
||||
|
||||
switch *align {
|
||||
case "left":
|
||||
table.SetAlignment(tablewriter.ALIGN_LEFT)
|
||||
case "right":
|
||||
table.SetAlignment(tablewriter.ALIGN_RIGHT)
|
||||
case "center":
|
||||
table.SetAlignment(tablewriter.ALIGN_CENTER)
|
||||
}
|
||||
table.SetBorder(*border)
|
||||
table.Render()
|
||||
}
|
||||
|
||||
func exit(err error) {
|
||||
fmt.Fprintf(os.Stderr, "#Error : %s", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue