author | Mikael Berthe <mikael@lilotux.net> |
Wed, 10 May 2017 20:13:31 +0200 | |
changeset 116 | 3dd35bdb63ac |
parent 115 | 8ae0dda7756d |
child 129 | 11966471aac3 |
permissions | -rw-r--r-- |
0 | 1 |
# madonctl |
2 |
||
3 |
Golang command line interface for the Mastodon API |
|
4 |
||
5 |
[![license](https://img.shields.io/badge/license-MIT-blue.svg?style=flat)](https://raw.githubusercontent.com/McKael/madonctl/master/LICENSE) |
|
2 | 6 |
[![Build Status](https://travis-ci.org/McKael/madonctl.svg?branch=master)](https://travis-ci.org/McKael/madonctl) |
0 | 7 |
|
8 |
`madonctl` is a [Go](https://golang.org/) CLI tool to use the Mastondon REST API. |
|
9 |
||
4
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
10 |
It is built on top of [madon](https://github.com/McKael/madon), my Golang implementation of the API. |
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
11 |
|
0 | 12 |
## Installation |
13 |
||
4
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
14 |
### From source |
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
15 |
|
37
9bc03db114c3
Add server statistics with gomif (using instances.mastodon.xyz API)
Mikael Berthe <mikael@lilotux.net>
parents:
32
diff
changeset
|
16 |
To install the application from source (you need to have Go >= 1.7), just type: |
0 | 17 |
|
54 | 18 |
go get -u github.com/McKael/madonctl |
0 | 19 |
|
4
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
20 |
and you should be able to run `madonctl`. |
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
21 |
|
54 | 22 |
For upgrades, don't forget the `-u` option to ensure the dependencies |
23 |
(especially [madon](https://github.com/McKael/madon)) are updated as well. |
|
21 | 24 |
|
25 |
Travis automated testing is run for Go versions 1.7 and 1.8. |
|
26 |
||
4
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
27 |
### Download |
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
28 |
|
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
29 |
Check the [Release page](https://github.com/McKael/madonctl/releases) for some pre-built binaries. |
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
30 |
|
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
31 |
More pre-built binaries are available from the [Homepage](https://lilotux.net/~mikael/pub/madonctl/) (development version and builds for a few other platforms). |
0 | 32 |
|
33 |
## Usage |
|
34 |
||
4
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
35 |
### Configuration |
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
36 |
|
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
37 |
In order to use madonctl, you need to specify the instance name or URL, and |
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
38 |
usually provide an account login/password (or a token). |
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
39 |
|
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
40 |
These settings can be passed as command line arguments or environment variables, |
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
41 |
but the easiest way is to use a configuration file. |
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
42 |
|
107 | 43 |
Note that you can **generate a configuration file** for your settings with |
4
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
44 |
|
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
45 |
`madonctl config dump -i mastodon.social -L username@domain -P password` |
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
46 |
|
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
47 |
(You can redirect the output to a configuration file.) |
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
48 |
|
115 | 49 |
If you only provide the Mastodon instance, it will generate a configuration |
50 |
file with an application ID/secret for this instance and you will have to add |
|
51 |
the user credentials. |
|
52 |
||
53 |
Note that every variable from the configration file can also be set with an |
|
54 |
environment variable (e.g. `export MADONCTL_INSTANCE='https://mamot.fr'`). |
|
55 |
||
56 |
If you don't want to use the password or if you have enabled *Two-factor |
|
57 |
authentication*, you can use **OAuth2** with the `oauth2` command, either |
|
58 |
interactively or non-interactively: |
|
59 |
||
60 |
`madonctl -i mastodon.social oauth2` |
|
4
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
61 |
|
115 | 62 |
The output is similar to the previous `config dump` command, so you can create |
63 |
your configuration file like this as well: |
|
64 |
||
65 |
`madonctl -i mastodon.social oauth2 > config_file.yaml` |
|
66 |
||
67 |
Note: If don't want to use the tool interactively, check to `get-url` and `code` |
|
68 |
subcommands: |
|
69 |
``` sh |
|
70 |
madonctl -i mastodon.social oauth2 get-url |
|
71 |
# (Paste the link into your browser...) |
|
72 |
madonctl -i mastodon.social code $CODE > config_file.yaml |
|
73 |
``` |
|
79
bca27c55be9f
Add default visibility setting
Mikael Berthe <mikael@lilotux.net>
parents:
75
diff
changeset
|
74 |
|
4
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
75 |
### Usage |
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
76 |
|
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
77 |
The complete list of commands is available in the online help (`madonctl help`, `madonctl command --help`...) |
108
cc73f7cb0f21
Update README again (style)
Mikael Berthe <mikael@lilotux.net>
parents:
107
diff
changeset
|
78 |
or in the [manpages](https://lilotux.net/~mikael/pub/madonctl/manual/html/).\ |
cc73f7cb0f21
Update README again (style)
Mikael Berthe <mikael@lilotux.net>
parents:
107
diff
changeset
|
79 |
The [Homepage](https://lilotux.net/~mikael/pub/madonctl/) also contains a plain list of commands. |
4
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
80 |
|
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
81 |
### Examples |
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
82 |
|
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
83 |
To post a simple "toot": |
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
84 |
``` sh |
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
85 |
% madonctl toot "Hello, World" |
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
86 |
``` |
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
87 |
|
108
cc73f7cb0f21
Update README again (style)
Mikael Berthe <mikael@lilotux.net>
parents:
107
diff
changeset
|
88 |
You can change the toot visibility, add a Content Warning (a.k.a. spoiler) |
cc73f7cb0f21
Update README again (style)
Mikael Berthe <mikael@lilotux.net>
parents:
107
diff
changeset
|
89 |
or send a media file: |
4
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
90 |
``` sh |
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
91 |
% madonctl toot --visibility direct "@McKael Hello, you" |
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
92 |
% madonctl toot --visibility private --spoiler CW "The answer was 42" |
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
93 |
% madonctl post --file image.jpg Selfie # Send a media file |
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
94 |
``` |
79
bca27c55be9f
Add default visibility setting
Mikael Berthe <mikael@lilotux.net>
parents:
75
diff
changeset
|
95 |
Note: The default toot visibility can be set in the configuration file with |
bca27c55be9f
Add default visibility setting
Mikael Berthe <mikael@lilotux.net>
parents:
75
diff
changeset
|
96 |
the `default_visibility` setting or with the environment variable (example |
bca27c55be9f
Add default visibility setting
Mikael Berthe <mikael@lilotux.net>
parents:
75
diff
changeset
|
97 |
`export MADONCTL_DEFAULT_VISIBILITY=unlisted`). |
4
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
98 |
|
17 | 99 |
Send (text) file content as new message: |
100 |
``` |
|
101 |
% madonctl toot --text-file message.txt |
|
102 |
``` |
|
103 |
||
72 | 104 |
... or read message from standard input: |
105 |
``` |
|
106 |
% echo "Hello from #madonctl" | madonctl toot --stdin |
|
107 |
``` |
|
108 |
||
107 | 109 |
Some **account-related commands**: |
4
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
110 |
``` sh |
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
111 |
% madonctl accounts blocked # List blocked accounts |
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
112 |
% madonctl accounts muted # List muted accounts |
31 | 113 |
% madonctl accounts notifications --list --all # List really all notifications |
4
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
114 |
% madonctl accounts notifications --list --clear # List and clear notifications |
19
4c81f4393773
Add notification --dismiss to clear a single notification
Mikael Berthe <mikael@lilotux.net>
parents:
17
diff
changeset
|
115 |
% madonctl accounts notifications --notification-id 1234 # Display notification |
4c81f4393773
Add notification --dismiss to clear a single notification
Mikael Berthe <mikael@lilotux.net>
parents:
17
diff
changeset
|
116 |
% madonctl accounts notifications --dismiss --notification-id 1234 # Mastodon 1.3+ |
4
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
117 |
``` |
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
118 |
|
32 | 119 |
Note: By default, madonctl will send a single query. If you want all available |
120 |
results you should use the `--all` flag. If you use a `--limit` value, |
|
121 |
madonctl might send several queries until the number of results reaches this |
|
122 |
value. |
|
123 |
||
107 | 124 |
**Update** your account information: |
7
df3e9e068778
Update documentation wrt accounts update
Mikael Berthe <mikael@lilotux.net>
parents:
5
diff
changeset
|
125 |
``` sh |
df3e9e068778
Update documentation wrt accounts update
Mikael Berthe <mikael@lilotux.net>
parents:
5
diff
changeset
|
126 |
% madonctl accounts update --display-name "John" # Update display name |
df3e9e068778
Update documentation wrt accounts update
Mikael Berthe <mikael@lilotux.net>
parents:
5
diff
changeset
|
127 |
% madonctl accounts update --note "Newcomer" # Update user note (bio) |
df3e9e068778
Update documentation wrt accounts update
Mikael Berthe <mikael@lilotux.net>
parents:
5
diff
changeset
|
128 |
% madonctl accounts update --note "" # Clear note |
df3e9e068778
Update documentation wrt accounts update
Mikael Berthe <mikael@lilotux.net>
parents:
5
diff
changeset
|
129 |
% madonctl accounts update --avatar me.png # Update avatar |
df3e9e068778
Update documentation wrt accounts update
Mikael Berthe <mikael@lilotux.net>
parents:
5
diff
changeset
|
130 |
``` |
df3e9e068778
Update documentation wrt accounts update
Mikael Berthe <mikael@lilotux.net>
parents:
5
diff
changeset
|
131 |
|
108
cc73f7cb0f21
Update README again (style)
Mikael Berthe <mikael@lilotux.net>
parents:
107
diff
changeset
|
132 |
See your own **posts**: |
31 | 133 |
``` sh |
134 |
% madonctl accounts statuses # See last posts |
|
135 |
% madonctl accounts statuses --all # See all statuses |
|
136 |
``` |
|
137 |
||
108
cc73f7cb0f21
Update README again (style)
Mikael Berthe <mikael@lilotux.net>
parents:
107
diff
changeset
|
138 |
Display accounts you're **following** or your **followers**: |
31 | 139 |
``` sh |
140 |
% madonctl accounts following # See last following |
|
141 |
% madonctl accounts following --all # See all followed accounts |
|
142 |
% madonctl accounts followers --limit 30 # Last 30 followers |
|
143 |
``` |
|
144 |
||
107 | 145 |
Add/remove a **favourite**, **boost** a status... |
4
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
146 |
``` sh |
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
147 |
% madonctl status --status-id 416671 favourite # Fave a status |
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
148 |
% madonctl status --status-id 416671 boost # Boost a status |
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
149 |
``` |
0 | 150 |
|
5
d70f8e8f3d2e
Add examples with accounts and timelines
Mikael Berthe <mikael@lilotux.net>
parents:
4
diff
changeset
|
151 |
Search for an account (only accounts known to your instance): |
d70f8e8f3d2e
Add examples with accounts and timelines
Mikael Berthe <mikael@lilotux.net>
parents:
4
diff
changeset
|
152 |
``` sh |
d70f8e8f3d2e
Add examples with accounts and timelines
Mikael Berthe <mikael@lilotux.net>
parents:
4
diff
changeset
|
153 |
% madonctl accounts search gargron |
d70f8e8f3d2e
Add examples with accounts and timelines
Mikael Berthe <mikael@lilotux.net>
parents:
4
diff
changeset
|
154 |
``` |
d70f8e8f3d2e
Add examples with accounts and timelines
Mikael Berthe <mikael@lilotux.net>
parents:
4
diff
changeset
|
155 |
|
107 | 156 |
**Follow** an account with known ID: |
5
d70f8e8f3d2e
Add examples with accounts and timelines
Mikael Berthe <mikael@lilotux.net>
parents:
4
diff
changeset
|
157 |
``` sh |
d70f8e8f3d2e
Add examples with accounts and timelines
Mikael Berthe <mikael@lilotux.net>
parents:
4
diff
changeset
|
158 |
% madonctl accounts follow --account-id 1234 |
d70f8e8f3d2e
Add examples with accounts and timelines
Mikael Berthe <mikael@lilotux.net>
parents:
4
diff
changeset
|
159 |
``` |
d70f8e8f3d2e
Add examples with accounts and timelines
Mikael Berthe <mikael@lilotux.net>
parents:
4
diff
changeset
|
160 |
|
4
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
161 |
Follow a remote account: |
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
162 |
``` sh |
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
163 |
% madonctl accounts follow --remote Gargron@mastodon.social |
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
164 |
``` |
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
165 |
|
107 | 166 |
**Search** for accounts, statuses or hashtags: |
105 | 167 |
``` sh |
168 |
% madonctl search gargron |
|
169 |
% madonctl search mastodon |
|
170 |
``` |
|
171 |
||
172 |
When the account ID is unknown, --user-id can be useful.\ |
|
173 |
You can specify the (instance-specific) account ID number (--account-id) or |
|
174 |
the user ID (--user-id). In the later case, madonctl will search for the |
|
175 |
user so it must match exactly the ID known to your instance (without the |
|
176 |
@domain suffix if the user is on the same instance). With madonctl v0.6.1+, |
|
177 |
the --user-id flag can also contain an HTTP account URL. |
|
178 |
``` sh |
|
179 |
% madonctl accounts --user-id Gargron@mastodon.social -l5 # Last 5 statuses |
|
180 |
% madonctl accounts --user-id https://mastodon.social/@Gargron -l5 # Same |
|
181 |
``` |
|
182 |
||
107 | 183 |
Read **timelines**: |
5
d70f8e8f3d2e
Add examples with accounts and timelines
Mikael Berthe <mikael@lilotux.net>
parents:
4
diff
changeset
|
184 |
``` sh |
d70f8e8f3d2e
Add examples with accounts and timelines
Mikael Berthe <mikael@lilotux.net>
parents:
4
diff
changeset
|
185 |
% madonctl timeline # Display home timeline |
d70f8e8f3d2e
Add examples with accounts and timelines
Mikael Berthe <mikael@lilotux.net>
parents:
4
diff
changeset
|
186 |
% madonctl timeline public # Display federated timeline |
d70f8e8f3d2e
Add examples with accounts and timelines
Mikael Berthe <mikael@lilotux.net>
parents:
4
diff
changeset
|
187 |
% madonctl timeline public --local # Display public local timeline |
24 | 188 |
|
189 |
% madonctl timeline --limit 3 # Display 3 latest home timeline messages |
|
5
d70f8e8f3d2e
Add examples with accounts and timelines
Mikael Berthe <mikael@lilotux.net>
parents:
4
diff
changeset
|
190 |
``` |
d70f8e8f3d2e
Add examples with accounts and timelines
Mikael Berthe <mikael@lilotux.net>
parents:
4
diff
changeset
|
191 |
|
107 | 192 |
Use the **streaming API** and fetch timelines and notifications: |
4
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
193 |
``` sh |
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
194 |
% madonctl stream # Stream home timeline and notifications |
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
195 |
% madonctl stream local # Stream local timeline |
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
196 |
% madonctl stream public # Stream federated timeline |
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
197 |
``` |
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
198 |
|
107 | 199 |
You can also use **hashtag streams**: |
75
447ac88b67c6
Update README documentation wrt streams
Mikael Berthe <mikael@lilotux.net>
parents:
72
diff
changeset
|
200 |
``` sh |
447ac88b67c6
Update README documentation wrt streams
Mikael Berthe <mikael@lilotux.net>
parents:
72
diff
changeset
|
201 |
% madonctl stream :mastodon # Stream for hastag 'mastodon' |
447ac88b67c6
Update README documentation wrt streams
Mikael Berthe <mikael@lilotux.net>
parents:
72
diff
changeset
|
202 |
% madonctl stream :madonctl,golang # Stream for several hashtags |
447ac88b67c6
Update README documentation wrt streams
Mikael Berthe <mikael@lilotux.net>
parents:
72
diff
changeset
|
203 |
``` |
447ac88b67c6
Update README documentation wrt streams
Mikael Berthe <mikael@lilotux.net>
parents:
72
diff
changeset
|
204 |
|
447ac88b67c6
Update README documentation wrt streams
Mikael Berthe <mikael@lilotux.net>
parents:
72
diff
changeset
|
205 |
Please note that madonctl will use one socket per stream, so the number of |
447ac88b67c6
Update README documentation wrt streams
Mikael Berthe <mikael@lilotux.net>
parents:
72
diff
changeset
|
206 |
concurrent hashtags is currently limited to 4 for "politeness". |
447ac88b67c6
Update README documentation wrt streams
Mikael Berthe <mikael@lilotux.net>
parents:
72
diff
changeset
|
207 |
|
115 | 208 |
It is also possible to send every stream event (notification or status) to |
209 |
an **external command**. You can can even combine it with a customized theme. |
|
210 |
The contents will be sent to the standard input of this command: |
|
211 |
``` sh |
|
212 |
madonctl stream --command gateway.sh --theme gateway |
|
213 |
``` |
|
75
447ac88b67c6
Update README documentation wrt streams
Mikael Berthe <mikael@lilotux.net>
parents:
72
diff
changeset
|
214 |
|
108
cc73f7cb0f21
Update README again (style)
Mikael Berthe <mikael@lilotux.net>
parents:
107
diff
changeset
|
215 |
(Almost) All commands have a **customizable output**: |
4
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
216 |
``` sh |
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
217 |
% madonctl accounts show # Display an account |
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
218 |
% madonctl accounts show -o yaml # Display an account, in yaml |
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
219 |
% madonctl accounts show -o json # Display an account, in json |
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
220 |
% madonctl stream local -o json # Stream local timeline and output to JSON |
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
221 |
``` |
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
222 |
|
107 | 223 |
You can also use Go (Golang) **templates**: |
4
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
224 |
``` sh |
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
225 |
% madonctl accounts --account-id 1 followers --template '{{.acct}}{{"\n"}}' |
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
226 |
``` |
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
227 |
|
102
84ad56b643c8
Allow HTTP URLs in --user-id
Mikael Berthe <mikael@lilotux.net>
parents:
98
diff
changeset
|
228 |
Number of users on current instance (statistics from instances.mastodon.xyz API): |
37
9bc03db114c3
Add server statistics with gomif (using instances.mastodon.xyz API)
Mikael Berthe <mikael@lilotux.net>
parents:
32
diff
changeset
|
229 |
``` |
9bc03db114c3
Add server statistics with gomif (using instances.mastodon.xyz API)
Mikael Berthe <mikael@lilotux.net>
parents:
32
diff
changeset
|
230 |
madonctl instance --stats --template '{{printf "%v\n" .users}}' |
9bc03db114c3
Add server statistics with gomif (using instances.mastodon.xyz API)
Mikael Berthe <mikael@lilotux.net>
parents:
32
diff
changeset
|
231 |
``` |
9bc03db114c3
Add server statistics with gomif (using instances.mastodon.xyz API)
Mikael Berthe <mikael@lilotux.net>
parents:
32
diff
changeset
|
232 |
|
92 | 233 |
You can write and use [themes](templates) as well (madonctl 0.6+): |
234 |
``` |
|
235 |
madonctl --theme=ansi timeline |
|
236 |
``` |
|
237 |
||
4
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
238 |
There are many more commands, you can find them in the online help or the manpage. |
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
239 |
|
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
240 |
|
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
241 |
### Shell completion |
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
242 |
|
107 | 243 |
If you want **shell completion**, you can generate scripts with the following command: \ |
4
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
244 |
`madonctl completion bash` (or zsh) |
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
245 |
|
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
246 |
Then, just source the script in your shell. |
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
247 |
|
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
248 |
For example, I have this line in my .zshrc: |
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
249 |
|
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
250 |
`source <(madonctl completion zsh)` |
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
251 |
|
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
252 |
### Commands output |
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
253 |
|
107 | 254 |
The output can be set to **json**, **yaml** or to a **Go template** for all commands.\ |
4
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
255 |
If you are familiar with Kubernetes' kubectl, it is very similar. |
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
256 |
|
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
257 |
For example, you can display your user token with:\ |
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
258 |
`madonctl config whoami --template '{{.access_token}}'`\ |
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
259 |
or the application ID with:\ |
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
260 |
`madonctl config dump --template '{{.ID}}'` |
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
261 |
|
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
262 |
All the users that have favorited a given status:\ |
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
263 |
`madonctl status --status-id 101194 favourited-by --template '{{.username}}{{"\n"}}'` |
a3b95e2f0b0b
Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents:
2
diff
changeset
|
264 |
|
107 | 265 |
Sets of templates can be grouped as **themes**. |
105 | 266 |
|
24 | 267 |
For more complex templates, one can use the `--template-file` option.\ |
105 | 268 |
See the [themes & templates](templates) folder. |
0 | 269 |
|
270 |
## References |
|
271 |
||
272 |
- [madon](https://github.com/McKael/madon), the Go library for Mastodon API |
|
273 |
- [Mastodon API documentation](https://github.com/tootsuite/documentation/blob/master/Using-the-API/API.md) |
|
274 |
- [Mastodon repository](https://github.com/tootsuite/mastodon) |