镜像来自
https://github.com/therootcompany/golib.git
synced 2025-10-29 20:22:51 +00:00
feat(gsheet2env): add -d to change delimiter
This commit is contained in:
父節點
f882bfc139
當前提交
7513e62a6c
@ -22,12 +22,19 @@ func isValidKey(key string) bool {
|
||||
}
|
||||
|
||||
func main() {
|
||||
delimString := flag.String("d", ",", "field delimiter to use for output file ('\\t' for tab, '^_' for Unit Separator, etc)")
|
||||
noShebang := flag.Bool("no-shebang", false, "don't begin the file with #!/bin/sh")
|
||||
noHeader := flag.Bool("no-header", false, "treat all non-comment rows as ENVs - don't expect a header")
|
||||
noExport := flag.Bool("no-export", false, "disable export prefix")
|
||||
outputFile := flag.String("o", "-", "path to output env file (default: stdout)")
|
||||
flag.Parse()
|
||||
|
||||
delim, err := gsheet2csv.DecodeDelimiter(*delimString)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error decoding output delimiter: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// Require Google Sheet URL as argument
|
||||
if len(flag.Args()) != 1 {
|
||||
fmt.Fprintf(os.Stderr, "Error: exactly one Google Sheet URL or path is required\n")
|
||||
@ -54,6 +61,7 @@ func main() {
|
||||
gsr := gsheet2csv.NewReaderFrom(gsheetURLOrPath)
|
||||
// preserves comment-looking data (and actual comments)
|
||||
gsr.Comment = 0
|
||||
gsr.Comma = delim
|
||||
gsr.FieldsPerRecord = -1
|
||||
|
||||
if !*noShebang {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user