Skip to content

Commit

Permalink
release v1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
skanehira committed Feb 23, 2019
1 parent b7ccddd commit decd5d3
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 1 deletion.
23 changes: 23 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Go parameters
GOBUILD=go build
GOCLEAN=go clean
BINARY_NAME=gjo

export GO111MODULE=on

all: build

clean:
$(GOCLEAN)

build: clean
$(GOBUILD) -o $(BINARY_NAME)

# copy to $GOBIN
install: build
cp -f $(BINARY_NAME) $(GOBIN)/

# build release binary
release: clean
GOOS=darwin GOARCH=amd64 $(GOBUILD) && zip MacOS.zip $(BINARY_NAME) && rm -rf $(BINARY_NAME)
GOOS=linux GOARCH=amd64 $(GOBUILD) && zip Linux.zip $(BINARY_NAME) && rm -rf $(BINARY_NAME)
24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
# jo
# gjo
Small utility to create JSON objects.
This was inspired by [jpmens/jo](https://github.com/jpmens/jo).

![sreenshot](./screenshot.png)

## Requirements
- Go 1.1.14~
- Git

## Installtion
```sh
$ git clone https://github.com/skanehira/gjo.git
$ cd gjo
$ GO111MODULE=on go install
```

## Usage
```sh
$ gjo name=gorilla age=26 isGorilla=true
{"age":"26","isGorilla":true,"name":"gorilla"}
```

## Author
gorilla0513
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module github.com/skanehira/gjo
39 changes: 39 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package main

import (
"encoding/json"
"flag"
"fmt"
"strings"
)

func main() {
flag.Parse()
args := flag.Args()

jsons := make(map[string]interface{}, len(args))

for _, arg := range flag.Args() {
kv := strings.Split(arg, "=")
if len(kv) == 2 {
key, value := kv[0], kv[1]

switch value {
case "true":
jsons[key] = true
case "false":
jsons[key] = false
default:
jsons[key] = value
}
}
}

if len(jsons) != 0 {
output, err := json.Marshal(jsons)
if err != nil {
panic(err)
}
fmt.Println(string(output))
}
}
Binary file added screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit decd5d3

Please sign in to comment.