5 [![license](https://img.shields.io/badge/license-MIT-blue.svg?style=flat)](https://raw.githubusercontent.com/McKael/madonctl/master/LICENSE) |
5 [![license](https://img.shields.io/badge/license-MIT-blue.svg?style=flat)](https://raw.githubusercontent.com/McKael/madonctl/master/LICENSE) |
6 [![Build Status](https://travis-ci.org/McKael/madonctl.svg?branch=master)](https://travis-ci.org/McKael/madonctl) |
6 [![Build Status](https://travis-ci.org/McKael/madonctl.svg?branch=master)](https://travis-ci.org/McKael/madonctl) |
7 |
7 |
8 `madonctl` is a [Go](https://golang.org/) CLI tool to use the Mastondon REST API. |
8 `madonctl` is a [Go](https://golang.org/) CLI tool to use the Mastondon REST API. |
9 |
9 |
|
10 It is built on top of [madon](https://github.com/McKael/madon), my Golang implementation of the API. |
|
11 |
10 ## Installation |
12 ## Installation |
11 |
13 |
12 To install the application (you need to have Go): |
14 ### From source |
|
15 |
|
16 To install the application from source (you need to have Go), just type: |
13 |
17 |
14 go get github.com/McKael/madonctl |
18 go get github.com/McKael/madonctl |
15 |
19 |
16 Some pre-built binaries are available on the home page (see below). |
20 and you should be able to run `madonctl`. |
|
21 |
|
22 ### Download |
|
23 |
|
24 Check the [Release page](https://github.com/McKael/madonctl/releases) for some pre-built binaries. |
|
25 |
|
26 More pre-built binaries are available from the [Homepage](https://lilotux.net/~mikael/pub/madonctl/) (development version and builds for a few other platforms). |
17 |
27 |
18 ## Usage |
28 ## Usage |
19 |
29 |
20 This section has not been written yet. |
30 ### Configuration |
21 |
31 |
22 Please check the [Homepage](https://lilotux.net/~mikael/pub/madonctl/) for an |
32 In order to use madonctl, you need to specify the instance name or URL, and |
23 introduction and a few examples. |
33 usually provide an account login/password (or a token). |
|
34 |
|
35 These settings can be passed as command line arguments or environment variables, |
|
36 but the easiest way is to use a configuration file. |
|
37 |
|
38 Note that you can generate a configuration file for your settings with |
|
39 |
|
40 `madonctl config dump -i mastodon.social -L username@domain -P password` |
|
41 |
|
42 (You can redirect the output to a configuration file.) |
|
43 |
|
44 If you only provide the Mastodon instance, it will generate a configuration file with an application ID/secret for this instance and you will have to add the user credentials. |
|
45 |
|
46 ### Usage |
|
47 |
|
48 The complete list of commands is available in the online help (`madonctl help`, `madonctl command --help`...) |
|
49 or in the [manpages](https://lilotux.net/~mikael/pub/madonctl/manual/html/). The [Homepage](https://lilotux.net/~mikael/pub/madonctl/) also contains a plain list of commands. |
|
50 |
|
51 ### Examples |
|
52 |
|
53 To post a simple "toot": |
|
54 ``` sh |
|
55 % madonctl toot "Hello, World" |
|
56 ``` |
|
57 |
|
58 You can change the toot visibility, add a Content Warning (a.k.a. spoiler) or send a media file: |
|
59 ``` sh |
|
60 % madonctl toot --visibility direct "@McKael Hello, you" |
|
61 % madonctl toot --visibility private --spoiler CW "The answer was 42" |
|
62 % madonctl post --file image.jpg Selfie # Send a media file |
|
63 ``` |
|
64 |
|
65 Some account-related commands: |
|
66 ``` sh |
|
67 % madonctl accounts blocked # List blocked accounts |
|
68 % madonctl accounts muted # List muted accounts |
|
69 % madonctl accounts notifications --list --clear # List and clear notifications |
|
70 ``` |
|
71 |
|
72 Add/remove a favourite, boost a status... |
|
73 ``` sh |
|
74 % madonctl status --status-id 416671 favourite # Fave a status |
|
75 % madonctl status --status-id 416671 boost # Boost a status |
|
76 ``` |
|
77 |
|
78 Follow a remote account: |
|
79 ``` sh |
|
80 % madonctl accounts follow --remote Gargron@mastodon.social |
|
81 ``` |
|
82 |
|
83 Use the streaming API and fetch timelines and notifications: |
|
84 ``` sh |
|
85 % madonctl stream # Stream home timeline and notifications |
|
86 % madonctl stream local # Stream local timeline |
|
87 % madonctl stream public # Stream federated timeline |
|
88 ``` |
|
89 |
|
90 (Almost) All commands have a customisable outpput |
|
91 ``` sh |
|
92 % madonctl accounts show # Display an account |
|
93 % madonctl accounts show -o yaml # Display an account, in yaml |
|
94 % madonctl accounts show -o json # Display an account, in json |
|
95 % madonctl stream local -o json # Stream local timeline and output to JSON |
|
96 ``` |
|
97 |
|
98 You can also use Go (Golang) templates: |
|
99 ``` sh |
|
100 % madonctl accounts --account-id 1 followers --template '{{.acct}}{{"\n"}}' |
|
101 ``` |
|
102 |
|
103 There are many more commands, you can find them in the online help or the manpage. |
|
104 |
|
105 |
|
106 ### Shell completion |
|
107 |
|
108 If you want shell completion, you can generate scripts with the following command: \ |
|
109 `madonctl completion bash` (or zsh) |
|
110 |
|
111 Then, just source the script in your shell. |
|
112 |
|
113 For example, I have this line in my .zshrc: |
|
114 |
|
115 `source <(madonctl completion zsh)` |
|
116 |
|
117 ### Commands output |
|
118 |
|
119 The output can be set to json, yaml or to a Go template for all commands.\ |
|
120 If you are familiar with Kubernetes' kubectl, it is very similar. |
|
121 |
|
122 For example, you can display your user token with:\ |
|
123 `madonctl config whoami --template '{{.access_token}}'`\ |
|
124 or the application ID with:\ |
|
125 `madonctl config dump --template '{{.ID}}'` |
|
126 |
|
127 All the users that have favorited a given status:\ |
|
128 `madonctl status --status-id 101194 favourited-by --template '{{.username}}{{"\n"}}'` |
|
129 |
|
130 For more complex templates, one can use the `--template-file` option. |
24 |
131 |
25 ## References |
132 ## References |
26 |
133 |
27 - [madon](https://github.com/McKael/madon), the Go library for Mastodon API |
134 - [madon](https://github.com/McKael/madon), the Go library for Mastodon API |
28 - [Mastodon API documentation](https://github.com/tootsuite/documentation/blob/master/Using-the-API/API.md) |
135 - [Mastodon API documentation](https://github.com/tootsuite/documentation/blob/master/Using-the-API/API.md) |