Notice: Due to mastodon disabling basic auth in their api, toopt will no longer work unless you already have an access token. Apologies.
Toopt is a command-line posting utility for mastodon written in PHP.
Toopt can post text content from the command line, as well as from files, piped content, or interactively. Toopt can thread posts either automatically or deliberately. It allows for image uploads, with optional descriptions, and handles multiple accounts.
Toopt is written as a single file with no dependencies.
Toopt is written in PHP and requires the following:
- PHP (cli) 8.1 or higher
- the PHP posix extension
- the PHP curl extension
The shortest path to posting the first toot using Toopt is:
wget https://toopt.fruitbat.studio/toopt.php -O ./toopt.php
chmod 755 ./toopt.php
./toopt --add-account
./toopt "Hello World"
The easiest installation is to download directly.
Using curl:
curl https://toopt.fruitbat.studio/toopt.php > ./toopt.php
chmod 755 ./toopt.php
Or wget:
wget https://toopt.fruitbat.studio/toopt.php -O ./toopt.php
chmod 755 ./toopt.php
For the latest version, check out the repository and put the toopt.php
file anywhere in your path, set as executable.
There are two usage activities: managing accounts, and posting toots.
Before using toopt
, you need to set up your account or accounts.
To add a new account, call toopt
with the --add-account
argument:
toopt.php --add-account
Toopt will poll for login credentials. The account will be stored and set as the default account
To list all of your stored accounts, call toopt
with --list-accounts
:
toopt.php --list-accounts
The default account will be highlighted.
Accounts can be deleted from the store with --delete-account=
:
toopt.php --delete-account=@name@instance.social
The default account cannot be delted
The default account can be changed with --set-default-account
:
toopt.php --set-default-account=@name@instance.social
The simplest usage case is to post a single toot using your default account:
toopt.php "Hello world"
Tooting from an account other than the default account can be done using the --account=
argument
toopt.php --acount=@otheraccount@phpc.social "Hello world from other account"
Content warnings (or spoilers) can be added to toots using the --cw=
argument:
toopt.php --cw="warning! test content" "Hello world"
Toot content can be passed to toopt
from a file:
toopt.php /path/to/hello_world.txt
or multiple files (see 'Deliberate threading'):
toopt.php /path/to/file1.txt /path/to/file2
Files that have the file extension txt
or no file extension will be handled as toot content.
Toopt can read content piped in on STDIN
. For instance:
echo "Hello world" | toopt.php
Note: Content from STDIN
is given priority. If content is piped into to toopt
, all other content is ignored.
Content can be composed interactively using the -i
or --interactive
arguments:
toopt.php --interactive
The editor is a line editor. A confirmation prompt is shown before posting.
Content that is longer than 500 characters will be automatically threaded. Threads will be broken on newlines or punctuation, if possible. Thread footers, ie. "1/3", will be appended to the bottom of each toot.
A toot thread can be built by simply passing multiple toot arguments. ie.
toopt.php /path/to/toot1.txt /path/to/toot2.txt "this is toot3"
Files or string arguments can be used as toots for a thread. Toots are threaded with the left-most toot being the first, descending rightward.
Media files, such as images, can be posted by providing the path to the file as an argument:
toopt.php /path/to/image.jpeg
Media files are identified by their file extension. The accepted extensions are:
- jpg
- jpeg
- gif
- png
Multiple media files, up to a maximum of four, can be posted:
toopt.ph /path/to/img1.png /path/to/img2.jpg /path/to/img3.jpeg /path/to/img4.gif
If a thread is posted, either deliberately or via automatic threading, all media files will be attached to the first toot.
A text description can be added to a media file using the --description=
argument:
toopt.php --description="a nice picture" /path/to/image.jpeg
If multiple media are used, descriptions are applied to the media in the order they are provided. For instance:
toopt.php --description="img 1" ./img1.jpg --description="img 2" ./img2.jpg
or
toopt.php --description="img 1" --description="img 2" ./img1.jpg ./img2.jpg
Media and text content can be combined:
toopt.php "look at these two images" /path/to/img1.jpg /path/to/img2.jpg
or
toopt.php /path/to/toot.txt /path/to/img1.jpg /path/to/img2.jpg
or
echo "look at these two images" | toopt.php /path/to/img1.jpg /path/to/img2.jpg
Post a toot from the default account
toopt.php "This is a toot"
Post a toot as from an account other than default
toopt.php --account=@otheraccount@instance.social "This is a toot"
Post a toot with a content warning
toopt.php --cw="This is a content warning" "This is a toot"
Post a three-toot thread
toopt.php "This is toot 1" "This is toot2" "This is toot3"
Post a three-toot thread using a mix of files and string arguments
toopt.php "This is toot 1" /path/to/toot2.txt /path/to/toot3
Compose and post a toot interactively
toopt.php --interactive
or
toopt.php -i
Post a media file as a toot
toopt.php /path/to/image.jpg
Post several media files, up to four, as a toot
toopt.php /path/to/image.jpg /path/to/otherimage.jpg
Add descriptions to media files
toopt.php --description="description of image 1" /path/to/img1.jpg --description="description of image 2" /path/to/img2.jpg
Combine media and text
toopt.php "some text" /path/to/image.jpg
Display help
toopt.php --help