add search command
This commit is contained in:
parent
05c270286a
commit
eb5f3fd239
|
@ -3,7 +3,6 @@ package main
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"log"
|
"log"
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/mattn/go-mastodon"
|
"github.com/mattn/go-mastodon"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
|
@ -23,7 +22,7 @@ func cmdToot(c *cli.Context) error {
|
||||||
}
|
}
|
||||||
toot = string(text)
|
toot = string(text)
|
||||||
} else {
|
} else {
|
||||||
toot = strings.Join(c.Args().Tail(), " ")
|
toot = argstr(c)
|
||||||
}
|
}
|
||||||
client := c.App.Metadata["client"].(*mastodon.Client)
|
client := c.App.Metadata["client"].(*mastodon.Client)
|
||||||
_, err := client.PostStatus(&mastodon.Toot{
|
_, err := client.PostStatus(&mastodon.Toot{
|
||||||
|
|
|
@ -143,6 +143,14 @@ func authenticate(client *mastodon.Client, config *mastodon.Config, file string)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func argstr(c *cli.Context) string {
|
||||||
|
a := []string{}
|
||||||
|
for i := 0; i < c.NArg(); i++ {
|
||||||
|
a = append(a, c.Args().Get(i))
|
||||||
|
}
|
||||||
|
return strings.Join(a, " ")
|
||||||
|
}
|
||||||
|
|
||||||
func fatalIf(err error) {
|
func fatalIf(err error) {
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return
|
return
|
||||||
|
@ -207,6 +215,11 @@ func run() int {
|
||||||
Usage: "show account information",
|
Usage: "show account information",
|
||||||
Action: cmdAccount,
|
Action: cmdAccount,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Name: "search",
|
||||||
|
Usage: "search content",
|
||||||
|
Action: cmdSearch,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
app.Run(os.Args)
|
app.Run(os.Args)
|
||||||
return 0
|
return 0
|
||||||
|
|
Loading…
Reference in New Issue
Block a user