README.md
author Mikael Berthe <mikael@lilotux.net>
Fri, 21 Apr 2017 23:43:48 +0200
changeset 4 a3b95e2f0b0b
parent 2 b4a2df4425c4
child 5 d70f8e8f3d2e
permissions -rw-r--r--
Update README - add some documentation
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
5abace724584 Initial public release
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
     1
# madonctl
5abace724584 Initial public release
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
     2
5abace724584 Initial public release
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
     3
Golang command line interface for the Mastodon API
5abace724584 Initial public release
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
     4
5abace724584 Initial public release
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
     5
[![license](https://img.shields.io/badge/license-MIT-blue.svg?style=flat)](https://raw.githubusercontent.com/McKael/madonctl/master/LICENSE)
2
b4a2df4425c4 Add Travis status badge
Mikael Berthe <mikael@lilotux.net>
parents: 0
diff changeset
     6
[![Build Status](https://travis-ci.org/McKael/madonctl.svg?branch=master)](https://travis-ci.org/McKael/madonctl)
0
5abace724584 Initial public release
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
     7
5abace724584 Initial public release
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
     8
`madonctl` is a [Go](https://golang.org/) CLI tool to use the Mastondon REST API.
5abace724584 Initial public release
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
     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
5abace724584 Initial public release
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    12
## Installation
5abace724584 Initial public release
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    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
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
    16
To install the application from source (you need to have Go), just type:
0
5abace724584 Initial public release
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    17
5abace724584 Initial public release
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    18
    go get github.com/McKael/madonctl
5abace724584 Initial public release
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    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
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
    22
### Download
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
    23
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
    24
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
    25
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
    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).
0
5abace724584 Initial public release
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    27
5abace724584 Initial public release
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    28
## Usage
5abace724584 Initial public release
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    29
4
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
    30
### Configuration
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
    31
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
    32
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
    33
usually provide an account login/password (or a token).
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
    34
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
    35
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
    36
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
    37
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
    38
Note that you can generate a configuration file for your settings with
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
`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
    41
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
    42
(You can redirect the output to a configuration file.)
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
    43
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
    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.
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
    45
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
    46
### Usage
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
    47
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
    48
The complete list of commands is available in the online help (`madonctl help`, `madonctl command --help`...)
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
    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.
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
    50
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
    51
### Examples
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
    52
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
    53
To post a simple "toot":
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
    54
``` sh
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
    55
% madonctl toot "Hello, World"
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
    56
```
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
    57
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
    58
You can change the toot visibility, add a Content Warning (a.k.a. spoiler) or send a media file:
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
    59
``` sh
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
    60
% madonctl toot --visibility direct "@McKael Hello, you"
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
    61
% 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
    62
% 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
    63
```
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
    64
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
    65
Some account-related commands:
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
    66
``` sh
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
    67
% madonctl accounts blocked                       # List blocked accounts
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
    68
% madonctl accounts muted                         # List muted accounts
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
    69
% madonctl accounts notifications --list --clear  # List and clear notifications
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
    70
```
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
    71
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
    72
Add/remove a favourite, boost a status...
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
    73
``` sh
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
    74
% madonctl status --status-id 416671 favourite    # Fave a status
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
    75
% madonctl status --status-id 416671 boost        # Boost a status
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
    76
```
0
5abace724584 Initial public release
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    77
4
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
    78
Follow a remote account:
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
    79
``` sh
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
    80
% madonctl accounts follow --remote Gargron@mastodon.social
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
    81
```
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
Use the streaming API and fetch timelines and notifications:
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 stream                   # Stream home timeline and notifications
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
    86
% madonctl stream local             # Stream local timeline
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
    87
% madonctl stream public            # Stream federated timeline
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
    88
```
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
    89
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
    90
(Almost) All commands have a customisable outpput
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
    91
``` sh
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
    92
% madonctl accounts show            # Display an account
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
    93
% 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
    94
% 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
    95
% 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
    96
```
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
    97
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
    98
You can also use Go (Golang) templates:
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
    99
``` sh
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
   100
% madonctl accounts --account-id 1 followers --template '{{.acct}}{{"\n"}}'
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
   101
```
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
   102
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
   103
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
   104
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
   105
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
   106
### Shell completion
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
   107
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
   108
If you want shell completion, you can generate scripts with the following command: \
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
   109
`madonctl completion bash` (or zsh)
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
   110
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
   111
Then, just source the script in your shell.
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
   112
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
   113
For example, I have this line in my .zshrc:
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
   114
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
   115
`source <(madonctl completion zsh)`
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
   116
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
   117
### Commands output
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
   118
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
   119
The output can be set to json, yaml or to a Go template for all commands.\
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
   120
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
   121
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
   122
For example, you can display your user token with:\
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
   123
`madonctl config whoami --template '{{.access_token}}'`\
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
   124
or the application ID with:\
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
   125
`madonctl config dump --template '{{.ID}}'`
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
   126
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
   127
All the users that have favorited a given status:\
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
   128
`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
   129
a3b95e2f0b0b Update README - add some documentation
Mikael Berthe <mikael@lilotux.net>
parents: 2
diff changeset
   130
For more complex templates, one can use the `--template-file` option.
0
5abace724584 Initial public release
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
   131
5abace724584 Initial public release
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
   132
## References
5abace724584 Initial public release
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
   133
5abace724584 Initial public release
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
   134
- [madon](https://github.com/McKael/madon), the Go library for Mastodon API
5abace724584 Initial public release
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
   135
- [Mastodon API documentation](https://github.com/tootsuite/documentation/blob/master/Using-the-API/API.md)
5abace724584 Initial public release
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
   136
- [Mastodon repository](https://github.com/tootsuite/mastodon)