Compare commits

...

10 Commits
v0.1.0 ... main

6 changed files with 100 additions and 17 deletions

12
Cargo.lock generated
View File

@ -1,5 +1,7 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "adler"
version = "1.0.2"
@ -161,9 +163,9 @@ checksum = "9c59e7af012c713f529e7a3ee57ce9b31ddd858d4b512923602f74608b009631"
[[package]]
name = "bytemuck"
version = "1.7.0"
version = "1.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9966d2ab714d0f785dbac0a0396251a35280aeb42413281617d0209ab4898435"
checksum = "72957246c41db82b8ef88a5486143830adeb8227ef9837740bdec67724cf2c5b"
[[package]]
name = "byteorder"
@ -317,9 +319,9 @@ dependencies = [
[[package]]
name = "crossbeam-deque"
version = "0.8.0"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94af6efb46fef72616855b036a624cf27ba656ffc9be1b9a3c931cfc7749a9a9"
checksum = "6455c0ca19f0d2fbf751b908d5c55c1f5cbc65e03c4225427254b46890bdde1e"
dependencies = [
"cfg-if",
"crossbeam-epoch",
@ -1227,7 +1229,7 @@ dependencies = [
[[package]]
name = "mxadm"
version = "0.1.0"
version = "0.1.2"
dependencies = [
"anyhow",
"clap",

View File

@ -1,7 +1,7 @@
[package]
name = "mxadm"
description = "A simple CLI interface to basic Matrix room admin tasks"
version = "0.1.0"
version = "0.1.2"
authors = ["Jez Cope <j.cope@erambler.co.uk>"]
edition = "2018"
license = "GPL-3.0-or-later"

View File

@ -1,8 +1,83 @@
# mxadm: a simple CLI to automate Matrix room admin tasks
TODO: intro
`mxadm` is a simple command-line tool
to do some basic Matrix room admin tasks,
especially things which don't currently have a UI in [Element][],
or which are possible but require a fair bit of effort
(e.g. using Element's devtools).
TODO: policy on maintenance and contributions
[Element]: https://matrix.org/docs/projects/client/element
It should be considered unstable:
the command-line arguments will evolve
as the tool itself evolves,
but the functionality should roughly the same.
## Getting started
### Installation
Not yet packaged for any OS as far as I'm aware.
You can install it with Rust's `cargo` tool:
1. [Install Rust and Cargo](https://doc.rust-lang.org/cargo/getting-started/installation.html)
2. Install `mxadm`:
``` shellsession
$ cargo install mxadm
```
### Usage
The only documentation is currently via the tool itself:
``` shellsession
$ mxadm help
mxadm 0.1.0
Jez Cope <j.cope@erambler.co.uk>
A simple CLI interface to basic Matrix room admin tasks
USAGE:
mxadm [SUBCOMMAND]
FLAGS:
-h, --help Prints help information
-V, --version Prints version information
SUBCOMMANDS:
alias alias subcommands
help Prints this message or the help of the given subcommand(s)
login authenticates and saves the session details
logout ends the current session
room room subcommands
status displays current session status
```
## Development & contributions
[_See also license info_](#license)
This is a hobby project of mine,
developed for my own use case,
but I would be delighted if someone else wanted to use it!
If you find bugs or want to request new features
please feel free to [create a new issue](https://tildegit.org/petrichor/mxadm/issues/new)
(it's running gitea and you can sign in with GitHub or Twitter)
but bear in mind that it will probably take me some time
to get around to responding or doing something about it!
If you want something changing and have the skills,
a pull request/patch will probably be quicker,
but there will still be delays before I can review and merge it.
I'm also pretty new to Rust,
so my code may not be the best;
constructive code review very welcome!
### Contact me
- Matrix: [@jez:petrichor.me](https://matrix.to/#/@jez:petrichor.me)
- Fedi: [@petrichor@scholar.social](https://scholar.social/@petrichor)
- Twitter: [@jezcope](https://twitter.com/jezcope)
## TODO

View File

@ -8,7 +8,14 @@
let pkgs = nixpkgs.legacyPackages.${system};
in {
devShell = pkgs.mkShell {
buildInputs = with pkgs; [ cargo rustc rustfmt pkgconfig openssl.dev ];
buildInputs = with pkgs; [
rustup
rustracer
cargo-outdated
cargo-audit
pkgconfig
openssl.dev
];
};
});
}

View File

@ -1,4 +1,4 @@
#[deny(unsafe_code)]
#![deny(unsafe_code)]
#[macro_use]
extern crate clap;
#[macro_use]
@ -18,7 +18,7 @@ async fn main() -> Result<()> {
.subcommand(
SubCommand::with_name("login")
.about("authenticates and saves the session details")
.args_from_usage("-U, --user=[USERNAME] 'Specifies the username to log in with'"),
.args_from_usage("-U, --user=[MXID] 'Specifies the Matrix ID (like @you:example.com) to log in with'"),
)
.subcommand(SubCommand::with_name("logout").about("ends the current session"))
.subcommand(SubCommand::with_name("status").about("displays current session status"))
@ -34,8 +34,8 @@ async fn main() -> Result<()> {
SubCommand::with_name("tombstone")
.about("add a tombstone redirecting one room to another")
.args_from_usage(
"<OLD_ROOM_ID> 'The ID of the source room'
<NEW_ROOM_ID> 'The ID of the target room'",
"<OLD_ROOM_ID> 'The ID (like !aBcD:example.com) of the source room'
<NEW_ROOM_ID> 'The ID (like !pQrS:example.com) of the target room'",
)
.arg(
Arg::with_name("MSG")
@ -53,14 +53,14 @@ async fn main() -> Result<()> {
SubCommand::with_name("add")
.about("adds an alias to a room")
.args_from_usage(
"<ROOM_ID> 'The ID of the room to alias'
<ALIAS> 'The new alias to add'",
"<ROOM_ID> 'The ID (like !aBcD:example.com) of the room to alias'
<ALIAS> 'The new alias (like #alias:example.com) to add'",
),
)
.subcommand(
SubCommand::with_name("delete")
.about("deletes an existing alias")
.args_from_usage("<ALIAS> 'The alias to delete'"),
.args_from_usage("<ALIAS> 'The alias (like #alias:example.com) to delete'"),
),
);
let matches = app.get_matches();

View File

@ -1,7 +1,6 @@
use anyhow::{Context, Result};
use directories::ProjectDirs;
use matrix_sdk::{Client, ClientConfig, Session};
use serde_lexpr;
use std::fs::{create_dir_all, File};
use std::io::ErrorKind;