Skip to content

Latest commit

 

History

History
120 lines (81 loc) · 3.84 KB

File metadata and controls

120 lines (81 loc) · 3.84 KB

CLI

Usage

The command line tool, gss, can be used to easily convert data between formats. gss reads from stdin and outputs to stdout.

gss -i INPUT_FORMAT -o OUTPUT_FORMAT [flags]

Using typical shell redirection, you can read from INPUT_FILE and write to OUTPUT_FILE.

gss -i INPUT_FORMAT -o OUTPUT_FORMAT [flags] < INPUT_FILE > OUTPUT_FILE

Or you could save the output to shell variable output.

output=$(echo "${input}" | gss -i INPUT_FORMAT -o OUTPUT_FORMAT [flags])

For more information use the help flag.

gss --help

Formats

The following file formats are supported. Pull requests to support other formats are welcome!

Format Read Write Stream Description
bson - Binary JSON
csv Comma-Separated Values
fmt - fmt
go - Go (format specifier: "%#v")
gob gob
hcl - - HashiCorp Configuration Language
json - JSON
jsonl JSON Lines
properties - Properties
tags single-line series of key=value tags
toml - TOML
tsv Tab-Separated Values
yaml - YAML

Platforms

The following platforms are supported. Pull requests to support other platforms are welcome!

GOOS GOARCH
darwin amd64
linux amd64
windows amd64
linux arm64

Releases

gss is currently in alpha. Find releases at https://github.com/spatialcurrent/go-reader-writer/releases. See the Building section below to build from scratch.

Darwin

  • gss_darwin_amd64 - CLI for Darwin on amd64 (includes macOS and iOS platforms)

Linux

  • gss_linux_amd64 - CLI for Linux on amd64
  • gss_linux_amd64 - CLI for Linux on arm64

Windows

  • gss_windows_amd64.exe - CLI for Windows on amd64

Examples

.gitignore file to jsonl

cat .gitignore | gss -i csv --input-header path -o json

Get language from CircleCI config.

cat .circleci/config.yml | gss -i yaml -o json -c '#' | jq -r .version

Convert list of files to JSON Lines

find . -name '*.go' | gss -i csv --input-header path -o jsonl

Building

Use make build_cli to build executables for Linux and Windows.

Changing Destination

The default destination for build artifacts is gss/bin, but you can change the destination with an environment variable. For building on a Chromebook consider saving the artifacts in /usr/local/go/bin, e.g., DEST=/usr/local/go/bin make build_cli

Testing

To run CLI testes use make test_cli, which uses shUnit2. If you recive a shunit2:FATAL Please declare TMPDIR with path on partition with exec permission. error, you can modify the TMPDIR environment variable in line or with export TMPDIR=<YOUR TEMP DIRECTORY HERE>. For example:

TMPDIR="/usr/local/tmp" make test_cli