Skip to content

Commit

Permalink
Revert c0875d6.
Browse files Browse the repository at this point in the history
  • Loading branch information
mithrandie committed Jun 19, 2022
1 parent 2e7e0c2 commit 59d9bf4
Show file tree
Hide file tree
Showing 24 changed files with 216 additions and 92 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/coverage_profile_uploading.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Coverage profile uploading

on:
workflow_run:
workflows:
- Test
branches:
- master
- develop
types:
- completed

jobs:
upload:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}

steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.x

- name: Create Coverage Profile
run: go test -coverprofile=coverage.txt -covermode=atomic ./...

- name: Upload Coverage Profile
uses: codecov/codecov-action@v2
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.txt
fail_ci_if_error: true
verbose: true
fail:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'failure' }}

steps:
- run: |
echo '::error::Testing was failed'
exit 1
17 changes: 17 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Test

on: push

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.x

- name: Test
run: go test ./... --cover
17 changes: 17 additions & 0 deletions .github/workflows/test_on_the_previous_go_version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Test on the previous Go version

on: push

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.17.x

- name: Test
run: go test ./... --cover
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

SQL-like query language for csv

[![Build Status](https://travis-ci.org/mithrandie/csvq.svg?branch=master)](https://travis-ci.org/mithrandie/csvq)
[![Test](https://github.com/mithrandie/csvq/actions/workflows/test.yml/badge.svg)](https://github.com/mithrandie/csvq/actions/workflows/test.yml)
[![codecov](https://codecov.io/gh/mithrandie/csvq/branch/master/graph/badge.svg)](https://codecov.io/gh/mithrandie/csvq)
[![License: MIT](https://img.shields.io/badge/License-MIT-lightgrey.svg)](https://opensource.org/licenses/MIT)

csvq is a command line tool to operate CSV files.
You can read, update, delete CSV records with SQL-like query.
Expand Down Expand Up @@ -59,7 +60,7 @@ Go 1.17 or later (cf. [Getting Started - The Go Programming Language](https://go

#### Build command

```$ env GO111MODULE=on go get github.com/mithrandie/csvq```
```$ go install github.com/mithrandie/csvq```

### Install using package manager

Expand Down
2 changes: 1 addition & 1 deletion docs/_posts/2006-01-02-command.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ Regardless of this option, files with the following extensions will be read in a
: Strip line break from the end of files and query results.

--format value, -f value
: Format of query results. The default is _TEXT_.
: Format of query results. The default is _TEXT_, but _CSV_ is used for output to pipe.

| value(case ignored) | format |
|:--------------------|:-------------------------------------------------------------------|
Expand Down
2 changes: 1 addition & 1 deletion docs/_posts/2006-01-02-install.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Go 1.17 or later (cf. [Getting Started - The Go Programming Language](https://go

### Build command

```$ env GO111MODULE=on go get github.com/mithrandie/csvq```
```$ go install github.com/mithrandie/csvq```

## Install using package manager
{: #install-using-package-manager}
Expand Down
4 changes: 2 additions & 2 deletions docs/sitemap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
</url>
<url>
<loc>https://mithrandie.github.io/csvq/reference/install.html</loc>
<lastmod>2022-03-23T00:27:45+00:00</lastmod>
<lastmod>2022-06-18T18:12:31+00:00</lastmod>
</url>
<url>
<loc>https://mithrandie.github.io/csvq/reference/command.html</loc>
<lastmod>2022-06-17T12:04:02+00:00</lastmod>
<lastmod>2022-06-18T12:43:41+00:00</lastmod>
</url>
<url>
<loc>https://mithrandie.github.io/csvq/reference/statement.html</loc>
Expand Down
14 changes: 6 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,16 @@ module github.com/mithrandie/csvq

require (
github.com/mitchellh/go-homedir v1.0.0
github.com/mithrandie/go-file/v2 v2.0.2
github.com/mithrandie/go-file/v2 v2.1.0
github.com/mithrandie/go-text v1.5.3
github.com/mithrandie/readline-csvq v1.1.1
github.com/mithrandie/readline-csvq v1.2.0
github.com/mithrandie/ternary v1.1.1
github.com/urfave/cli v1.20.0
golang.org/x/crypto v0.0.0-20220315160706-3147a52a75dd
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e
golang.org/x/sys v0.0.0-20220615213510-4f61da869c0c
golang.org/x/text v0.3.7
)

require (
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 // indirect
golang.org/x/text v0.3.7 // indirect
)
require golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 // indirect

go 1.17
16 changes: 8 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
github.com/mitchellh/go-homedir v1.0.0 h1:vKb8ShqSby24Yrqr/yDYkuFz8d0WUjys40rvnGC8aR0=
github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mithrandie/go-file/v2 v2.0.2 h1:3/yzItlTssDX9wOZrj9MtRyXbr52OZURmXFMuvpJ6Fg=
github.com/mithrandie/go-file/v2 v2.0.2/go.mod h1:98a9loPjYr7ffsfwMDdJ7iH/dO8EXAca8XiI6SZpPV8=
github.com/mithrandie/go-file/v2 v2.1.0 h1:XA5Tl+73GXMDvgwSE3Sg0uC5FkLr3hnXs8SpUas0hyg=
github.com/mithrandie/go-file/v2 v2.1.0/go.mod h1:9YtTF3Xo59GqC1Pxw6KyGVcM/qubAMlxVsqI/u9r++c=
github.com/mithrandie/go-text v1.5.3 h1:A+/mtgUsr1EsoVKGb4sm8Suho/Biku9Sh2appII4Mo0=
github.com/mithrandie/go-text v1.5.3/go.mod h1:yaVYauF3TLf7LvjGrrQB/mffIkohXTXJpW9zQ206UL8=
github.com/mithrandie/readline-csvq v1.1.1 h1:kp9W5WPUAB+NOgW5axPdu8mZe1M9CP/D1xpabj39JVY=
github.com/mithrandie/readline-csvq v1.1.1/go.mod h1:eOJt0j6UI9lhwM/KP+v40ugarhXsnPIXStvkfIaq79E=
github.com/mithrandie/readline-csvq v1.2.0 h1:5GFbdWFP+2m57Yz+XLtKVIfyH0SjN9du51VT0x9WI40=
github.com/mithrandie/readline-csvq v1.2.0/go.mod h1:6Grnfrl8PHC448fV7f8RJNlHeoM+Z3w2QlYW+J9mA2I=
github.com/mithrandie/ternary v1.1.1 h1:k/joD6UGVYxHixYmSR8EGgDFNONBMqyD373xT4QRdC4=
github.com/mithrandie/ternary v1.1.1/go.mod h1:0D9Ba3+09K2TdSZO7/bFCC0GjSXetCvYuYq0u8FY/1g=
github.com/urfave/cli v1.20.0 h1:fDqGv3UG/4jbVl/QkFwEdddtEDjh/5Ov6X+0B/3bPaw=
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
golang.org/x/crypto v0.0.0-20220315160706-3147a52a75dd h1:XcWmESyNjXJMLahc3mqVQJcgSTDxFxhETVlfk9uGc38=
golang.org/x/crypto v0.0.0-20220315160706-3147a52a75dd/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e h1:T8NU3HyQ8ClP4SEE+KbFlg6n0NhuTsN4MyznaarGsZM=
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/sys v0.0.0-20191029155521-f43be2a4598c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1 h1:SrN+KX8Art/Sf4HNj6Zcz06G7VEz+7w9tdXTPOZ7+l4=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220615213510-4f61da869c0c h1:aFV+BgZ4svzjfabn8ERpuB4JI4N6/rdy1iusx77G3oU=
golang.org/x/sys v0.0.0-20220615213510-4f61da869c0c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 h1:v+OssWQX+hTHEmOBgwxdZxK4zHq3yOs8F9J7mk0PY8E=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
Expand Down
2 changes: 1 addition & 1 deletion init_windows.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build windows
//go:build windows

package main

Expand Down
2 changes: 1 addition & 1 deletion lib/action/signals_default.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build !darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!solaris,!windows
//go:build !darwin && !dragonfly && !freebsd && !linux && !netbsd && !openbsd && !solaris && !windows

package action

Expand Down
2 changes: 1 addition & 1 deletion lib/action/signals_posix.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build darwin dragonfly freebsd linux netbsd openbsd solaris windows
//go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || windows

package action

Expand Down
42 changes: 24 additions & 18 deletions lib/cmd/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -474,35 +474,41 @@ func (f *Flags) SetWithoutNull(b bool) {
f.ImportOptions.WithoutNull = b
}

func (f *Flags) SetFormat(s string, outfile string) error {
var fm Format
var escape = txjson.Backslash
var err error
func (f *Flags) SetFormat(s string, outfile string, canOutputToPipe bool) error {
if len(s) < 1 {
if len(outfile) < 1 {
if canOutputToPipe {
f.ExportOptions.Format = CSV
} else {
f.ExportOptions.Format = TEXT
}
return nil
}

switch s {
case "":
switch strings.ToLower(filepath.Ext(outfile)) {
case CsvExt:
fm = CSV
f.ExportOptions.Format = CSV
case TsvExt:
fm = TSV
f.ExportOptions.Format = TSV
case JsonExt:
fm = JSON
f.ExportOptions.Format = JSON
case JsonlExt:
fm = JSONL
f.ExportOptions.Format = JSONL
case LtsvExt:
fm = LTSV
f.ExportOptions.Format = LTSV
case GfmExt:
fm = GFM
f.ExportOptions.Format = GFM
case OrgExt:
fm = ORG
f.ExportOptions.Format = ORG
default:
return nil
}
default:
if fm, escape, err = ParseFormat(s, f.ExportOptions.JsonEscape); err != nil {
return err
f.ExportOptions.Format = TEXT
}
return nil
}

fm, escape, err := ParseFormat(s, f.ExportOptions.JsonEscape)
if err != nil {
return err
}

f.ExportOptions.Format = fm
Expand Down
Loading

0 comments on commit 59d9bf4

Please sign in to comment.