From b1152a55cd6543ffae65233c06e686c77d9c505e Mon Sep 17 00:00:00 2001 From: 178inaba <178inaba@users.noreply.github.com> Date: Thu, 27 Apr 2017 12:03:11 +0900 Subject: [PATCH 1/3] Fix README --- README.md | 34 +++++++++++++++++++++++++++++++++- cmd/mstdn/README.md | 27 +++++++++++++++++++-------- 2 files changed, 52 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index a3fd959..f5ddfb1 100644 --- a/README.md +++ b/README.md @@ -7,14 +7,45 @@ ## Usage +### Application + ```go package main import ( "context" "fmt" - "github.com/mattn/go-mastodon" "log" + + "github.com/mattn/go-mastodon" +) + +func main() { + app, err := mastodon.RegisterApp(context.Background(), &mastodon.AppConfig{ + Server: "https://mstdn.jp", + ClientName: "client-name", + Scopes: "read write follow", + Website: "https://github.com/mattn/go-mastodon", + }) + if err != nil { + log.Fatal(err) + } + fmt.Printf("client-id : %s\n", app.ClientID) + fmt.Printf("client-secret: %s\n", app.ClientSecret) +} +``` + +### Client + +```go +package main + +import ( + "context" + "fmt" + "log" + + "github.com/mattn/go-mastodon" ) func main() { @@ -36,6 +67,7 @@ func main() { } } ``` + ## Status of implementations * [x] GET /api/v1/accounts/:id diff --git a/cmd/mstdn/README.md b/cmd/mstdn/README.md index 5e3b917..6b2dd22 100644 --- a/cmd/mstdn/README.md +++ b/cmd/mstdn/README.md @@ -10,19 +10,30 @@ NAME: USAGE: mstdn [global options] command [command options] [arguments...] - + VERSION: 0.0.1 - + COMMANDS: - toot post toot - stream stream statuses - timeline show timeline - help, h Shows a list of commands or help for one command + toot post toot + stream stream statuses + timeline show timeline + notification show notification + instance show instance information + account show account information + search search content + follow follow account + followers show followers + upload upload file + delete delete status + init initialize profile + mikami search mikami + help, h Shows a list of commands or help for one command GLOBAL OPTIONS: - --help, -h show help - --version, -v print the version + --profile value profile name + --help, -h show help + --version, -v print the version ``` ## Installation From 43b274bbd29e832cfdf13f0a3d1730b1790088bd Mon Sep 17 00:00:00 2001 From: 178inaba <178inaba@users.noreply.github.com> Date: Thu, 27 Apr 2017 12:03:24 +0900 Subject: [PATCH 2/3] Add example --- example_test.go | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 example_test.go diff --git a/example_test.go b/example_test.go new file mode 100644 index 0000000..8eda8f3 --- /dev/null +++ b/example_test.go @@ -0,0 +1,42 @@ +package mastodon_test + +import ( + "context" + "fmt" + "log" + + "github.com/mattn/go-mastodon" +) + +func ExampleApplication_RegisterApp() { + app, err := mastodon.RegisterApp(context.Background(), &mastodon.AppConfig{ + Server: "https://mstdn.jp", + ClientName: "client-name", + Scopes: "read write follow", + Website: "https://github.com/mattn/go-mastodon", + }) + if err != nil { + log.Fatal(err) + } + fmt.Printf("client-id : %s\n", app.ClientID) + fmt.Printf("client-secret: %s\n", app.ClientSecret) +} + +func ExampleClient() { + c := mastodon.NewClient(&mastodon.Config{ + Server: "https://mstdn.jp", + ClientID: "client-id", + ClientSecret: "client-secret", + }) + err := c.Authenticate(context.Background(), "your-email", "your-password") + if err != nil { + log.Fatal(err) + } + timeline, err := c.GetTimelineHome(context.Background()) + if err != nil { + log.Fatal(err) + } + for i := len(timeline) - 1; i >= 0; i-- { + fmt.Println(timeline[i]) + } +} From 983ab89d48b188dee74299774e57cbc339e6f3c3 Mon Sep 17 00:00:00 2001 From: 178inaba <178inaba@users.noreply.github.com> Date: Thu, 27 Apr 2017 12:07:21 +0900 Subject: [PATCH 3/3] Fix example --- example_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example_test.go b/example_test.go index 8eda8f3..307b6d5 100644 --- a/example_test.go +++ b/example_test.go @@ -8,7 +8,7 @@ import ( "github.com/mattn/go-mastodon" ) -func ExampleApplication_RegisterApp() { +func ExampleRegisterApp() { app, err := mastodon.RegisterApp(context.Background(), &mastodon.AppConfig{ Server: "https://mstdn.jp", ClientName: "client-name",