README.md
changeset 105 07d96d963223
parent 102 84ad56b643c8
child 107 093fc00b333d
equal deleted inserted replaced
104:ce2b92d6d72c 105:07d96d963223
    38 usually provide an account login/password (or a token).
    38 usually provide an account login/password (or a token).
    39 
    39 
    40 These settings can be passed as command line arguments or environment variables,
    40 These settings can be passed as command line arguments or environment variables,
    41 but the easiest way is to use a configuration file.
    41 but the easiest way is to use a configuration file.
    42 
    42 
    43 Note that you can generate a configuration file for your settings with
    43 Note that you can *generate a configuration file* for your settings with
    44 
    44 
    45 `madonctl config dump -i mastodon.social -L username@domain -P password`
    45 `madonctl config dump -i mastodon.social -L username@domain -P password`
    46 
    46 
    47 (You can redirect the output to a configuration file.)
    47 (You can redirect the output to a configuration file.)
    48 
    48 
    80 ... or read message from standard input:
    80 ... or read message from standard input:
    81 ```
    81 ```
    82 % echo "Hello from #madonctl" | madonctl toot --stdin
    82 % echo "Hello from #madonctl" | madonctl toot --stdin
    83 ```
    83 ```
    84 
    84 
    85 Some account-related commands:
    85 Some *account-related commands*:
    86 ``` sh
    86 ``` sh
    87 % madonctl accounts blocked                       # List blocked accounts
    87 % madonctl accounts blocked                       # List blocked accounts
    88 % madonctl accounts muted                         # List muted accounts
    88 % madonctl accounts muted                         # List muted accounts
    89 % madonctl accounts notifications --list --all    # List really all notifications
    89 % madonctl accounts notifications --list --all    # List really all notifications
    90 % madonctl accounts notifications --list --clear  # List and clear notifications
    90 % madonctl accounts notifications --list --clear  # List and clear notifications
   107 
   107 
   108 See your own posts:
   108 See your own posts:
   109 ``` sh
   109 ``` sh
   110 % madonctl accounts statuses                      # See last posts
   110 % madonctl accounts statuses                      # See last posts
   111 % madonctl accounts statuses --all                # See all statuses
   111 % madonctl accounts statuses --all                # See all statuses
   112 % madonctl accounts --user-id Gargron@mastodon.social -l5 # Last 5 statuses
   112 ```
   113 ```
   113 
   114 
   114 Display accounts you're following or your followers:
       
   115 ``` sh
       
   116 % madonctl accounts following                     # See last following
       
   117 % madonctl accounts following --all               # See all followed accounts
       
   118 % madonctl accounts followers --limit 30          # Last 30 followers
       
   119 ```
       
   120 
       
   121 Add/remove a *favourite*, *boost* a status...
       
   122 ``` sh
       
   123 % madonctl status --status-id 416671 favourite    # Fave a status
       
   124 % madonctl status --status-id 416671 boost        # Boost a status
       
   125 ```
       
   126 
       
   127 Search for an account (only accounts known to your instance):
       
   128 ``` sh
       
   129 % madonctl accounts search gargron
       
   130 ```
       
   131 
       
   132 *Follow* an account with known ID:
       
   133 ``` sh
       
   134 % madonctl accounts follow --account-id 1234
       
   135 ```
       
   136 
       
   137 Follow a remote account:
       
   138 ``` sh
       
   139 % madonctl accounts follow --remote Gargron@mastodon.social
       
   140 ```
       
   141 
       
   142 *Search* for accounts, statuses or hashtags:
       
   143 ``` sh
       
   144 % madonctl search gargron
       
   145 % madonctl search mastodon
       
   146 ```
       
   147 
       
   148 When the account ID is unknown, --user-id can be useful.\
   115 You can specify the (instance-specific) account ID number (--account-id) or
   149 You can specify the (instance-specific) account ID number (--account-id) or
   116 the user ID (--user-id).  In the later case, madonctl will search for the
   150 the user ID (--user-id).  In the later case, madonctl will search for the
   117 user so it must match exactly the ID known to your instance (without the
   151 user so it must match exactly the ID known to your instance (without the
   118 @domain suffix if the user is on the same instance).  With madonctl v0.6.1+,
   152 @domain suffix if the user is on the same instance).  With madonctl v0.6.1+,
   119 the --user-id flag can also contain an HTTP account URL.
   153 the --user-id flag can also contain an HTTP account URL.
   120 
   154 ``` sh
   121 Display accounts you're following or your followers:
   155 % madonctl accounts --user-id Gargron@mastodon.social -l5 # Last 5 statuses
   122 ``` sh
   156 % madonctl accounts --user-id https://mastodon.social/@Gargron -l5 # Same
   123 % madonctl accounts following                     # See last following
   157 ```
   124 % madonctl accounts following --all               # See all followed accounts
   158 
   125 % madonctl accounts followers --limit 30          # Last 30 followers
   159 Read *timelines*:
   126 ```
       
   127 
       
   128 Add/remove a favourite, boost a status...
       
   129 ``` sh
       
   130 % madonctl status --status-id 416671 favourite    # Fave a status
       
   131 % madonctl status --status-id 416671 boost        # Boost a status
       
   132 ```
       
   133 
       
   134 Search for an account (only accounts known to your instance):
       
   135 ``` sh
       
   136 % madonctl accounts search gargron
       
   137 ```
       
   138 
       
   139 Follow an account with known ID:
       
   140 ``` sh
       
   141 % madonctl accounts follow --account-id 1234
       
   142 ```
       
   143 
       
   144 Follow a remote account:
       
   145 ``` sh
       
   146 % madonctl accounts follow --remote Gargron@mastodon.social
       
   147 ```
       
   148 
       
   149 Read timelines:
       
   150 ``` sh
   160 ``` sh
   151 % madonctl timeline                 # Display home timeline
   161 % madonctl timeline                 # Display home timeline
   152 % madonctl timeline public          # Display federated timeline
   162 % madonctl timeline public          # Display federated timeline
   153 % madonctl timeline public --local  # Display public local timeline
   163 % madonctl timeline public --local  # Display public local timeline
   154 
   164 
   155 % madonctl timeline --limit 3       # Display 3 latest home timeline messages
   165 % madonctl timeline --limit 3       # Display 3 latest home timeline messages
   156 ```
   166 ```
   157 
   167 
   158 Use the streaming API and fetch timelines and notifications:
   168 Use the *streaming API* and fetch timelines and notifications:
   159 ``` sh
   169 ``` sh
   160 % madonctl stream                   # Stream home timeline and notifications
   170 % madonctl stream                   # Stream home timeline and notifications
   161 % madonctl stream local             # Stream local timeline
   171 % madonctl stream local             # Stream local timeline
   162 % madonctl stream public            # Stream federated timeline
   172 % madonctl stream public            # Stream federated timeline
   163 ```
   173 ```
   164 
   174 
   165 You can also use hashtag streams:
   175 You can also use *hashtag streams*:
   166 ``` sh
   176 ``` sh
   167 % madonctl stream :mastodon         # Stream for hastag 'mastodon'
   177 % madonctl stream :mastodon         # Stream for hastag 'mastodon'
   168 % madonctl stream :madonctl,golang  # Stream for several hashtags
   178 % madonctl stream :madonctl,golang  # Stream for several hashtags
   169 ```
   179 ```
   170 
   180 
   171 Please note that madonctl will use one socket per stream, so the number of
   181 Please note that madonctl will use one socket per stream, so the number of
   172 concurrent hashtags is currently limited to 4 for "politeness".
   182 concurrent hashtags is currently limited to 4 for "politeness".
   173 
   183 
   174 
   184 
   175 (Almost) All commands have a customisable output:
   185 (Almost) All commands have a *customisable output*:
   176 ``` sh
   186 ``` sh
   177 % madonctl accounts show            # Display an account
   187 % madonctl accounts show            # Display an account
   178 % madonctl accounts show -o yaml    # Display an account, in yaml
   188 % madonctl accounts show -o yaml    # Display an account, in yaml
   179 % madonctl accounts show -o json    # Display an account, in json
   189 % madonctl accounts show -o json    # Display an account, in json
   180 % madonctl stream local -o json     # Stream local timeline and output to JSON
   190 % madonctl stream local -o json     # Stream local timeline and output to JSON
   181 ```
   191 ```
   182 
   192 
   183 You can also use Go (Golang) templates:
   193 You can also use Go (Golang) *templates*:
   184 ``` sh
   194 ``` sh
   185 % madonctl accounts --account-id 1 followers --template '{{.acct}}{{"\n"}}'
   195 % madonctl accounts --account-id 1 followers --template '{{.acct}}{{"\n"}}'
   186 ```
   196 ```
   187 
   197 
   188 Number of users on current instance (statistics from instances.mastodon.xyz API):
   198 Number of users on current instance (statistics from instances.mastodon.xyz API):
   198 There are many more commands, you can find them in the online help or the manpage.
   208 There are many more commands, you can find them in the online help or the manpage.
   199 
   209 
   200 
   210 
   201 ### Shell completion
   211 ### Shell completion
   202 
   212 
   203 If you want shell completion, you can generate scripts with the following command: \
   213 If you want *shell completion*, you can generate scripts with the following command: \
   204 `madonctl completion bash` (or zsh)
   214 `madonctl completion bash` (or zsh)
   205 
   215 
   206 Then, just source the script in your shell.
   216 Then, just source the script in your shell.
   207 
   217 
   208 For example, I have this line in my .zshrc:
   218 For example, I have this line in my .zshrc:
   209 
   219 
   210 `source <(madonctl completion zsh)`
   220 `source <(madonctl completion zsh)`
   211 
   221 
   212 ### Commands output
   222 ### Commands output
   213 
   223 
   214 The output can be set to json, yaml or to a Go template for all commands.\
   224 The output can be set to *json*, *yaml* or to a *Go template* for all commands.\
   215 If you are familiar with Kubernetes' kubectl, it is very similar.
   225 If you are familiar with Kubernetes' kubectl, it is very similar.
   216 
   226 
   217 For example, you can display your user token with:\
   227 For example, you can display your user token with:\
   218 `madonctl config whoami --template '{{.access_token}}'`\
   228 `madonctl config whoami --template '{{.access_token}}'`\
   219 or the application ID with:\
   229 or the application ID with:\
   220 `madonctl config dump --template '{{.ID}}'`
   230 `madonctl config dump --template '{{.ID}}'`
   221 
   231 
   222 All the users that have favorited a given status:\
   232 All the users that have favorited a given status:\
   223 `madonctl status --status-id 101194 favourited-by --template '{{.username}}{{"\n"}}'`
   233 `madonctl status --status-id 101194 favourited-by --template '{{.username}}{{"\n"}}'`
   224 
   234 
       
   235 Sets of templates can be grouped as *themes*.
       
   236 
   225 For more complex templates, one can use the `--template-file` option.\
   237 For more complex templates, one can use the `--template-file` option.\
   226 See the [templates](templates) folder.
   238 See the [themes & templates](templates) folder.
   227 
   239 
   228 ## References
   240 ## References
   229 
   241 
   230 - [madon](https://github.com/McKael/madon), the Go library for Mastodon API
   242 - [madon](https://github.com/McKael/madon), the Go library for Mastodon API
   231 - [Mastodon API documentation](https://github.com/tootsuite/documentation/blob/master/Using-the-API/API.md)
   243 - [Mastodon API documentation](https://github.com/tootsuite/documentation/blob/master/Using-the-API/API.md)