Skip to content

Commit 25043b5

Browse files
Merge branch 'main' into Issue-79-sql-script
2 parents a3501eb + cd63a70 commit 25043b5

File tree

12 files changed

+598
-122
lines changed

12 files changed

+598
-122
lines changed

.github/workflows/ci.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v3
15+
16+
- name: Set up Go
17+
uses: actions/setup-go@v5
18+
with:
19+
go-version: stable
20+
21+
- name: Install dependencies
22+
run: go get .
23+
24+
- name: Formatting
25+
run: if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then gofmt -s -l .; exit 1; fi
26+
27+
- name: Run tests
28+
run: make test

Makefile

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
BIN_DIR=bin
22
DIST_DIR=dist
3-
CMD_DIR=cmd
4-
CSV_DIR=csv
53
EXECUTABLE=gocsv
64

75
.DEFAULT_GOAL := bin
@@ -11,8 +9,7 @@ dist:
119
bash scripts/build-dist.sh
1210

1311
test:
14-
cd $(CMD_DIR) && go test -cover
15-
cd $(CSV_DIR) && go test -cover
12+
go test -cover ./...
1613

1714
bin:
1815
bash scripts/build-bin.sh

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ Arguments:
369369
- `--case-insensitive` (optional, shorthand `-i`) Use this flag to specify a case insensitive match for replacement rather than the default case sensitive match.
370370
- `--repl` String to use for replacement.
371371

372-
Note that if you have a capture group in the `--regex` argument you can reference that in the replacement argument using `"\$1"` for the first capture group, `"\$2"` for the second capture group, etc.
372+
Note that if you have a capture group in the `--regex` argument you can reference that in the replacement argument using `"\$1"` for the first capture group, `"\$2"` for the second capture group, etc. In Windows cmd, the `\` escape is unnecessary, and the capture group references should be specifed as `"$1"` and `"$2"`.
373373

374374
### sample
375375

@@ -428,13 +428,14 @@ Split a CSV into multiple files.
428428
Usage:
429429
430430
```shell
431-
gocsv split --max-rows N [--filename-base FILENAME] FILE
431+
gocsv split --max-rows N [--filename-base FILENAME] [--width N] FILE
432432
```
433433
434434
Arguments:
435435
436436
- `--max-rows` Maximum number of rows per final CSV.
437437
- `--filename-base` (optional) Prefix of the resulting files. The file outputs will be appended with `"-1.csv"`,`"-2.csv"`, etc. If not specified, the base filename will be the same as the base of the input filename, unless the input is specified by standard input. If so, then the base filename will be `out`.
438+
- `--width` (optional) Minimum width of the numeric suffix, zero-padded if necessary. For example, `--width 3` results in filenames like `"file-001.csv"`, `"file-002.csv"`, etc.
438439
439440
### sql
440441
@@ -568,15 +569,15 @@ The command defaults to writing all converted sheets to a directory with the sam
568569
569570
Usage:
570571
571-
```none
572+
```shell
572573
gocsv xlsx [--list-sheets | --dirname DIRNAME | --sheet SHEET] FILE
573574
```
574575
575576
Arguments:
576577
577578
- `--list-sheets` (optional) List the sheets, by index and name, in the XLSX file.
578579
- `--sheet` (optional) Specify a single sheet, by index or name, to convert and write to stdout.
579-
- `--dirname` (optional) Specify the name of the directory for the converted sheets. The command defaults to the same name as `FILE`, minus the extension.
580+
- `--dirname` (optional) Specify the name of the directory for the converted sheets. The command defaults to the same name as `FILE`, minus the extension.
580581
581582
Only one option can be used; multiple options cannot be combined.
582583

cmd/delimiter.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ func (sub *DelimiterSubcommand) Description() string {
2020
return "Change the delimiter being used for a CSV."
2121
}
2222
func (sub *DelimiterSubcommand) SetFlags(fs *flag.FlagSet) {
23-
fs.StringVar(&sub.inputDelimiter, "input", "", "Input delimiter")
24-
fs.StringVar(&sub.inputDelimiter, "i", "", "Input delimiter (shorthand)")
25-
fs.StringVar(&sub.outputDelimiter, "output", "", "Output delimiter")
26-
fs.StringVar(&sub.outputDelimiter, "o", "", "Output delimiter (shorthand)")
23+
fs.StringVar(&sub.inputDelimiter, "input", ",", "Input delimiter")
24+
fs.StringVar(&sub.inputDelimiter, "i", ",", "Input delimiter (shorthand)")
25+
fs.StringVar(&sub.outputDelimiter, "output", ",", "Output delimiter")
26+
fs.StringVar(&sub.outputDelimiter, "o", ",", "Output delimiter (shorthand)")
2727
}
2828

2929
func (sub *DelimiterSubcommand) Run(args []string) {

0 commit comments

Comments
 (0)