This CLI allows you to manage your personal posts from the command line. It requires creating a project and app on the X Developer Portal to generate the necessary API keys and secrets.
> x --help
USAGE:
x [OPTIONS] <COMMAND>
EXAMPLES:
x post "Hello, world!" --media path/to/image.png
OPTIONS:
-h, --help Prints help information
COMMANDS:
auth
post <TEXT>
Authentication is managed for you by the CLI, using the Git Credential Manager as the cross-platform secure storage for your API key(s). You can login multiple project/key combination and then just change the active one without ever re-entering the keys.
See getting access on X for more details.
> x auth login --help
DESCRIPTION:
Authenticate to X by providing the required secrets.
Supports API key autentication using the Git Credential Manager for storage.
Switch easily between keys by just specifying an alias for the keys.
Alternatively, x will use the secrets found in environment variables with the
prefix `X_`: `X_AccessToken`, `X_AccessTokenSecret`, `X_ConsumerKey`,
`X_ConsumerSecret`.
Using double underscores also works for nested configuration, such as
`X__ConsumerKey`.
This method is most suitable for "headless" use such as in automation.
For example, to use x in GitHub Actions:
- name: ✖️ post
env:
X_AccessToken: ${{ secrets.X_ACCESS_TOKEN }}
X_AccessTokenSecret: ${{ secrets.X_ACCESS_TOKEN_SECRET }}
X_ConsumerKey: ${{ secrets.X_CONSUMER_KEY }}
X_ConsumerSecret: ${{ secrets.X_CONSUMER_SECRET }}
run: |
dotnet tool update -g dotnet-x
x post "Hello, world!" --media image.png
USAGE:
x auth login <alias> [OPTIONS]
ARGUMENTS:
<alias> Alias to use for the set of credentials
OPTIONS:
-h, --help Prints help information
--at Access token. Required unless previously saved
--ats Access token secret. Required unless previously saved
--ck Consumer key. Required unless previously saved
--cs Consumer secret. Required unless previously saved
> x auth logout --help
DESCRIPTION:
Log out of X
USAGE:
x auth logout [alias] [OPTIONS]
ARGUMENTS:
[alias] Specific alias to log out. Removes all accounts if not provided
OPTIONS:
-h, --help Prints help information
> x auth status --help
DESCRIPTION:
Shows the current authentication status
USAGE:
x auth status [OPTIONS]
OPTIONS:
-h, --help Prints help information
--show-secrets Display the secrets
> x post --help
USAGE:
x post <TEXT> [OPTIONS]
EXAMPLES:
x post "Hello, world!" --media path/to/image.png
ARGUMENTS:
<TEXT> Text to post
OPTIONS:
-h, --help Prints help information
--jq [EXPRESSION] Filter JSON output using a jq expression
--json Output as JSON. Implied when using --jq
--monochrome Disable colors when rendering JSON to the console
-m, --media <MEDIA> Zero or more media files to attach to the post
(.jpg, .jpeg, .png, .gif, .webp, .mp4, .mov)