Skip to content

Commit

Permalink
update 0.3.6
Browse files Browse the repository at this point in the history
  • Loading branch information
syui committed May 17, 2020
1 parent ebfa938 commit 30c5685
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
index.xml
news.xml
index.*
news.*
xq
go.sum
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ before_install:

script:
- gox -output "dist/{{.OS}}_{{.Arch}}_{{.Dir}}"
- ghr --username syui --token $GITHUB_TOKEN --replace --debug 0.3.5 dist/
- ghr --username syui --token $GITHUB_TOKEN --replace --debug 0.3.6 dist/
18 changes: 17 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,20 @@ $ xq l d index.xml
$ xq l a index.xml
```

convert md to json{body}.

```sh
$ cat index.txt
### :emoji: test
```sh
code
```
markdown "json".

$ xq j index.txt
{"body":"### :emoji: test\n```sh\ncode\n```\nmarkdown \"json\".\n"}
```

## update

- 0.2.0 : urfave/cli/v2
Expand All @@ -115,4 +129,6 @@ $ xq l a index.xml

- 0.3.4 : change option/update -> latest, $ xq latest ./index.xml

- 0.3.5 : change option/update -> latest, $ xq latest author ./index.xml
- 0.3.5 : add sub-command -> author, $ xq latest author ./index.xml

- 0.3.6 : add option/json, $ xq json ./index.txt
23 changes: 23 additions & 0 deletions xq.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,17 @@ import (
"fmt"
"os"
"encoding/json"
"io/ioutil"
"github.com/urfave/cli/v2"
"github.com/mmcdole/gofeed"
"github.com/mmcdole/gofeed/rss"
_ "reflect"
)

type JSONData struct {
body string
}

type MyCustomTranslator struct {
defaultTranslator *gofeed.DefaultRSSTranslator
}
Expand Down Expand Up @@ -227,6 +232,24 @@ func main() {
return nil
},
},
{
Name: "json",
Aliases: []string{"j"},
Usage: "xq j ./index.txt",
Action: func(c *cli.Context) error {
b, err := ioutil.ReadFile(c.Args().First())
if err != nil {
fmt.Println(os.Stderr, err)
os.Exit(1)
}
m := map[string]interface{}{
"body":string(b),
}
s, _ := json.Marshal(m)
fmt.Println(string(s))
return nil
},
},
}
app.Run(os.Args)
}

0 comments on commit 30c5685

Please sign in to comment.