Browse Source

add alias sub-command

master
syui 2 years ago
parent
commit
a6bdfefa45
No known key found for this signature in database GPG Key ID: ED2A0F5F1DA25512
  1. 2
      .travis.yml
  2. 42
      readme.md
  3. 7
      xq.go

2
.travis.yml

@ -14,4 +14,4 @@ before_install:
script:
- gox -output "dist/{{.OS}}_{{.Arch}}_{{.Dir}}"
- ghr --username syui --token $GITHUB_TOKEN --replace --debug 0.3.1 dist/
- ghr --username syui --token $GITHUB_TOKEN --replace --debug 0.3.2 dist/

42
readme.md

@ -1,3 +1,5 @@
`xq` converts xml to json.
## download
```sh
@ -9,6 +11,15 @@ $ go get -v github.com/syui/xq
```sh
$ xq /path/to/rss.xml
[{"title":"Creating a new theme","link":"https://syui.gitlab.io/test-hugo-theme-wave/2016/01/01/creating-a-new-theme/","date":"2018-01-16T00:00:00.000+09:00"}, {"title":"Archive","link":"https://syui.gitlab.io/test-hugo-theme-wave/archive/","date":"2018-01-16T00:00:00.000+09:00"}]
$ xq /path/to/rss.xml|jq .
[
{
"title": "Creating a new theme",
"link": "https://syui.gitlab.io/test-hugo-theme-wave/2016/01/01/creating-a-new-theme/",
"date": "2018-01-16T00:00:00.000+09:00"
}
]
```
## build
@ -25,29 +36,43 @@ $ ./xq h
```sh
$ curl -sLO https://syui.cf/hugo-theme-air/index.xml
$ xq i ./index.xml
{
$ xq ./index.xml
[{"title":"Creating a new theme","link":"https://syui.gitlab.io/test-hugo-theme-wave/2016/01/01/creating-a-new-theme/","date":"2018-01-16T00:00:00.000+09:00"}, {"title":"Archive","link":"https://syui.gitlab.io/test-hugo-theme-wave/archive/","date":"2018-01-16T00:00:00.000+09:00"}]
$ xq i index.xml
[{
"title": "Creating a new theme",
"link": "https://syui.gitlab.io/test-hugo-theme-wave/2016/01/01/creating-a-new-theme/",
"date": "2018-01-16T00:00:00.000+09:00"
}
}]
# latest update
$ xq u index.xml
2018-01-23T00:00:00.000+09:00
# latest post
$ xq p index.xml
2018-01-16T00:00:00.000+09:00
# latest item link
$ xq l link index.xml
$ xq l l index.xml
https://syui.gitlab.io/test-hugo-theme-wave/2016/01/01/creating-a-new-theme/
# latest item title
$ xq l title index.xml
$ xq l t index.xml
Creating a new theme
# latest item publish
$ xq l published index.xml
$ xq l p index.xml
$ xq p index.xml
2018-01-16T00:00:00.000+09:00
# latest update
$ xq u index.xml
2018-01-16T00:00:00.000+09:00
# latest item description
$ xq l description index.xml
$ xq l d index.xml
```
## update
@ -60,7 +85,10 @@ $ xq u index.xml
- 0.2.3 : fix option/[i]tem
- 0.2.4 : option/none, $ xq file
- 0.2.4 : option/none, $ xq file.xml
- 0.3.0 : option/[l]atest, sub-command/{link, title, published, description}, $ xq l link ./index.xml
- 0.3.1 : fix version, $ xq v
- 0.3.2 : add alias sub-command, $ xq l d ./index.xml

7
xq.go

@ -13,7 +13,6 @@ func App() *cli.App {
app := cli.NewApp()
app.Name = "xq"
app.Usage = "xq /path/to/rss.xml"
app.Version = "0.3.1"
return app
}
@ -42,7 +41,7 @@ func Action(c *cli.Context) {
func main() {
app := &cli.App{
Version: "0.3.1",
Version: "0.3.2",
Name: "xq",
Usage: "$ xq index.xml",
Action: func(c *cli.Context) error {
@ -100,6 +99,7 @@ func main() {
Subcommands: []*cli.Command{
{
Name: "link",
Aliases: []string{"l"},
Usage: "xq l link ./index.xml #latest item link",
Action: func(c *cli.Context) error {
file, _ := os.Open(c.Args().First())
@ -113,6 +113,7 @@ func main() {
},
{
Name: "title",
Aliases: []string{"t"},
Usage: "xq l title ./index.xml #latest itme title",
Action: func(c *cli.Context) error {
file, _ := os.Open(c.Args().First())
@ -126,6 +127,7 @@ func main() {
},
{
Name: "description",
Aliases: []string{"d"},
Usage: "xq l description ./index.xml #latest itme description",
Action: func(c *cli.Context) error {
file, _ := os.Open(c.Args().First())
@ -139,6 +141,7 @@ func main() {
},
{
Name: "published",
Aliases: []string{"p"},
Usage: "xq l published ./index.xml #latest itme published",
Action: func(c *cli.Context) error {
file, _ := os.Open(c.Args().First())

Loading…
Cancel
Save