Musket
Musket is a command line interface to send a URL to several destinations. Each destination handle the URL depending the nature of the destination, for example, Turso destination stores the URL in Turso Service (a SQLite database SaaS) and LinkedIn destination publish the link in the user profile.
Usage
1.- Install
2.- Create the configuration file
To create the configuration file, execute:
Musket uses a configuration file named config.toml. This file is placed in the directory musket inside the users's home. This home depends of the operating system:
The
musket loadcommand will display the full path to the configuration file.
3.- Configure the destinations
All destinations have to be configured from the configuration file.
Before sending a URL to LinkedIn destination you must:
- Create a LinkedIn Application with the Share on LinkedIn and Sign In with LinkedIn using OpenID Connect products added to the application.
- Create an access token with the email, openid, profile, w_member_social permissions.
- Get the author identifier (doing a request to the userinfo endpoint using the access token).
- Fill the
linkedinsection in the Musket configuration file. You must provide:- the
tokenused as a bearer authentication. - the
authoridentifier. share_commentaryis the text that will be shown in the post along the link.visibility, can be "PUBLIC" or "CONNECTIONS".
- the
Turso
Before sending a URL to Turso destination you must:
- Create a Turso account.
- Create a Turso Database.
- Create a Table with the following schema:
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
url TEXT,
tags TEXT,
created DATETIME
);
- Fill the
tursosection in the Musket configuration file. You must provide the databaseurland the tursotoken.
4.- Sending a URL
For example:
or
Run musket -h to get the details of each subcommand and arguments.
Contributing
Requirements
Last stable Rust toolchain. Use Rustup to install it.
Guidelines
- Use Conventional Commits.
- Use Feature Branch creating a pull request to main.
- Use Semantic Versioning.
Adding destinations
To add new destinations you must follow the next steps:
Info: Use the existing destinations code files as a source of information.
1. Define the configuration
In the config.rs file, add a struct to define the new destination configuration.
For example:
Add a field in the Configuration struct with the destination as a name and the destination configuration as a type:
2. Create a module
Create a file with the name of the new destination inside destinations folder.
This file must:
- have a public
structwith the fields needed to configure the destination. This fields must bepub. - implement
Destinationtrait. - implement
Fromtrait forDestinationError.
Once created, add the new module as a public module in the destination module inside the mod.rs file.
For example:
3. Manage new destination from the CLI
In the cli.rs file, add the new destination as a variant of the enum Destinations.
4. Create a Command
Create a file with the name of the new destination inside commands folder.
This file must implement a function named execute in charge of perform the sending of the URL (and tags if needed) to the destination.
Once created, add the new module as a public module in the commands module inside the mod.rs file.
For example:
5. Manage new destination from the lib
In the ['lib.rs](./src/lib.rs) file, add the new destination as a pattern matching of the Firecommand, and add a call to the command created above. Remember to add the command to theDestinations::All` match.
For example:
All =>
Turso =>
LinkedIn =>
6. Update the documentation
In the README.md file, add a documentation about how to configure the new destination inside the section Configure the destinations.