Skip to content

Commit

Permalink
Bump to 1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jehiah committed Mar 22, 2017
1 parent 7c45cd2 commit b654775
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 19 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
json2csv
dist
build

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

Expand Down
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: go
go:
- 1.5.3
- 1.6
- 1.7
- 1.8
sudo: false
install:
- go get github.com/bmizerany/assert
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Converts a stream of newline separated json data to csv format.
Installation
============

pre-built binaries are available under [releases](https://github.com/jehiah/json2csv/releases).

If you have a working golang install, you can use `go get`.

```bash
Expand All @@ -23,7 +25,6 @@ usage: json2csv
-k fields,and,nested.fields,to,output
-i /path/to/input.json (optional; default is stdin)
-o /path/to/output.csv (optional; default is stdout)
-v verbose output (to stderr)
--version
-p print csv header row
-h This help
Expand Down
31 changes: 31 additions & 0 deletions dist.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

# build binary distributions for linux/amd64 and darwin/amd64
set -e

DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
echo "working dir $DIR"

echo "... running tests"
go test|| exit 1

arch=$(go env GOARCH)
version=$(cat $DIR/version.go | grep "const VERSION" | awk '{print $NF}' | sed 's/"//g')
goversion=$(go version | awk '{print $3}')

for os in linux darwin; do
echo "... building v$version for $os/$arch"
BUILD=$(mktemp -d -t json2csv)
TARGET="json2csv-$version.$os-$arch.$goversion"
GOOS=$os GOARCH=$arch CGO_ENABLED=0 go build
mkdir -p $BUILD/$TARGET
cp json2csv $BUILD/$TARGET/json2csv
pushd $BUILD >/dev/null
tar czvf $TARGET.tar.gz $TARGET
if [ -e $DIR/dist/$TARGET.tar.gz ]; then
echo "... WARNING overwriting dist/$TARGET.tar.gz"
fi
mv $TARGET.tar.gz $DIR/dist
echo "... built dist/$TARGET.tar.gz"
popd >/dev/null
done
23 changes: 8 additions & 15 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,18 @@ type LineReader interface {
ReadBytes(delim byte) (line []byte, err error)
}

var (
inputFile = flag.String("i", "", "/path/to/input.json (optional; default is stdin)")
outputFile = flag.String("o", "", "/path/to/output.csv (optional; default is stdout)")
outputDelim = flag.String("d", ",", "delimiter used for output values")
verbose = flag.Bool("v", false, "verbose output (to stderr)")
showVersion = flag.Bool("version", false, "print version string")
printHeader = flag.Bool("p", false, "prints header to output")
keys = StringArray{}
)

func init() {
flag.Var(&keys, "k", "fields to output")
}

func main() {
inputFile := flag.String("i", "", "/path/to/input.json (optional; default is stdin)")
outputFile := flag.String("o", "", "/path/to/output.csv (optional; default is stdout)")
outputDelim := flag.String("d", ",", "delimiter used for output values")
showVersion := flag.Bool("version", false, "print version string")
printHeader := flag.Bool("p", false, "prints header to output")
keys := StringArray{}
flag.Var(&keys, "k", "fields to output")
flag.Parse()

if *showVersion {
fmt.Printf("json2csv v1.1\n")
fmt.Printf("json2csv %s\n", VERSION)
return
}

Expand Down
3 changes: 2 additions & 1 deletion main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ package main
import (
"bytes"
"encoding/csv"
"github.com/bmizerany/assert"
"io/ioutil"
"log"
"os"
"testing"

"github.com/bmizerany/assert"
)

func TestGetTopic(t *testing.T) {
Expand Down
3 changes: 3 additions & 0 deletions version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package main

const VERSION = "1.2.0"

0 comments on commit b654775

Please sign in to comment.