Skip to content

Commit d40f54a

Browse files
authored
Merge pull request #32 from jehiah/bump_32
Release v1.2
2 parents 7c45cd2 + b654775 commit d40f54a

File tree

7 files changed

+50
-19
lines changed

7 files changed

+50
-19
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
json2csv
2+
dist
3+
build
24

35
# from https://github.com/github/gitignore/blob/master/Go.gitignore
46

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
language: go
22
go:
3-
- 1.5.3
4-
- 1.6
3+
- 1.7
4+
- 1.8
55
sudo: false
66
install:
77
- go get github.com/bmizerany/assert

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ Converts a stream of newline separated json data to csv format.
99
Installation
1010
============
1111

12+
pre-built binaries are available under [releases](https://github.com/jehiah/json2csv/releases).
13+
1214
If you have a working golang install, you can use `go get`.
1315

1416
```bash
@@ -23,7 +25,6 @@ usage: json2csv
2325
-k fields,and,nested.fields,to,output
2426
-i /path/to/input.json (optional; default is stdin)
2527
-o /path/to/output.csv (optional; default is stdout)
26-
-v verbose output (to stderr)
2728
--version
2829
-p print csv header row
2930
-h This help

dist.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
3+
# build binary distributions for linux/amd64 and darwin/amd64
4+
set -e
5+
6+
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
7+
echo "working dir $DIR"
8+
9+
echo "... running tests"
10+
go test|| exit 1
11+
12+
arch=$(go env GOARCH)
13+
version=$(cat $DIR/version.go | grep "const VERSION" | awk '{print $NF}' | sed 's/"//g')
14+
goversion=$(go version | awk '{print $3}')
15+
16+
for os in linux darwin; do
17+
echo "... building v$version for $os/$arch"
18+
BUILD=$(mktemp -d -t json2csv)
19+
TARGET="json2csv-$version.$os-$arch.$goversion"
20+
GOOS=$os GOARCH=$arch CGO_ENABLED=0 go build
21+
mkdir -p $BUILD/$TARGET
22+
cp json2csv $BUILD/$TARGET/json2csv
23+
pushd $BUILD >/dev/null
24+
tar czvf $TARGET.tar.gz $TARGET
25+
if [ -e $DIR/dist/$TARGET.tar.gz ]; then
26+
echo "... WARNING overwriting dist/$TARGET.tar.gz"
27+
fi
28+
mv $TARGET.tar.gz $DIR/dist
29+
echo "... built dist/$TARGET.tar.gz"
30+
popd >/dev/null
31+
done

main.go

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,18 @@ type LineReader interface {
1818
ReadBytes(delim byte) (line []byte, err error)
1919
}
2020

21-
var (
22-
inputFile = flag.String("i", "", "/path/to/input.json (optional; default is stdin)")
23-
outputFile = flag.String("o", "", "/path/to/output.csv (optional; default is stdout)")
24-
outputDelim = flag.String("d", ",", "delimiter used for output values")
25-
verbose = flag.Bool("v", false, "verbose output (to stderr)")
26-
showVersion = flag.Bool("version", false, "print version string")
27-
printHeader = flag.Bool("p", false, "prints header to output")
28-
keys = StringArray{}
29-
)
30-
31-
func init() {
32-
flag.Var(&keys, "k", "fields to output")
33-
}
34-
3521
func main() {
22+
inputFile := flag.String("i", "", "/path/to/input.json (optional; default is stdin)")
23+
outputFile := flag.String("o", "", "/path/to/output.csv (optional; default is stdout)")
24+
outputDelim := flag.String("d", ",", "delimiter used for output values")
25+
showVersion := flag.Bool("version", false, "print version string")
26+
printHeader := flag.Bool("p", false, "prints header to output")
27+
keys := StringArray{}
28+
flag.Var(&keys, "k", "fields to output")
3629
flag.Parse()
3730

3831
if *showVersion {
39-
fmt.Printf("json2csv v1.1\n")
32+
fmt.Printf("json2csv %s\n", VERSION)
4033
return
4134
}
4235

main_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ package main
33
import (
44
"bytes"
55
"encoding/csv"
6-
"github.com/bmizerany/assert"
76
"io/ioutil"
87
"log"
98
"os"
109
"testing"
10+
11+
"github.com/bmizerany/assert"
1112
)
1213

1314
func TestGetTopic(t *testing.T) {

version.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package main
2+
3+
const VERSION = "1.2.0"

0 commit comments

Comments
 (0)