Commit 540d3a9b6d
Unsigned
Layout: unified · split
build.rs +12
| @@ -27,4 +27,16 @@ fn main() { | ||
| 27 | 27 | } else { |
| 28 | 28 | println!("cargo::rustc-cfg=weechat410"); |
| 29 | 29 | } |
| 30 | ||
| 31 | // Capture git describe output for the version command | |
| 32 | if let Ok(output) = std::process::Command::new("git") | |
| 33 | .args(["describe", "--long", "--tags", "--always", "--all", "--dirty"]) | |
| 34 | .current_dir(std::env::var("CARGO_MANIFEST_DIR").unwrap()) | |
| 35 | .output() | |
| 36 | { | |
| 37 | if output.status.success() { | |
| 38 | let describe = String::from_utf8_lossy(&output.stdout).trim().to_string(); | |
| 39 | println!("cargo::rustc-env=GIT_DESCRIBE={}", describe); | |
| 40 | } | |
| 41 | } | |
| 30 | 42 | } |
src/commands/matrix.rs +15 −1
| @@ -44,6 +44,7 @@ impl MatrixCommand { | ||
| 44 | 44 | .add_argument("reconnect <server-name>") |
| 45 | 45 | .add_argument("sso-complete <server-name> <login-token>") |
| 46 | 46 | .add_argument("read") |
| 47 | .add_argument("version") | |
| 47 | 48 | .add_argument("help <matrix-command> [<matrix-subcommand>]") |
| 48 | 49 | .arguments_description(format!( |
| 49 | 50 | " server: List, add, or remove Matrix servers. |
| @@ -53,6 +54,7 @@ impl MatrixCommand { | ||
| 53 | 54 | join: Join a Matrix room by ID or alias. |
| 54 | 55 | sso-complete: Finish SSO login with a copied loginToken. |
| 55 | 56 | read: Mark the current room as read. |
| 57 | version: Show version information about weechat-matrix. | |
| 56 | 58 | devices: {} |
| 57 | 59 | keys: {} |
| 58 | 60 | media: {} |
| @@ -77,7 +79,7 @@ Use /matrix [command] help to find out more.\n", | ||
| 77 | 79 | .add_completion("reconnect %(matrix_servers)") |
| 78 | 80 | .add_completion("sso-complete %(matrix_servers)") |
| 79 | 81 | .add_completion( |
| 80 | "help server|connect|disconnect|reconnect|join|sso-complete|read|keys|devices|media", | |
| 82 | "help server|connect|disconnect|reconnect|join|sso-complete|read|version|keys|devices|media", | |
| 81 | 83 | ); |
| 82 | 84 | |
| 83 | 85 | Command::new( |
| @@ -292,6 +294,14 @@ Use /matrix [command] help to find out more.\n", | ||
| 292 | 294 | room.mark_as_read(); |
| 293 | 295 | } |
| 294 | 296 | } |
| 297 | ("version", _) => { | |
| 298 | Weechat::print(&format!( | |
| 299 | "{}: weechat-matrix version {} ({})", | |
| 300 | PLUGIN_NAME, | |
| 301 | env!("CARGO_PKG_VERSION"), | |
| 302 | option_env!("GIT_DESCRIBE").unwrap_or("unknown"), | |
| 303 | )); | |
| 304 | } | |
| 295 | 305 | _ => unreachable!(), |
| 296 | 306 | } |
| 297 | 307 | } |
| @@ -416,6 +426,10 @@ impl CommandCallback for MatrixCommand { | ||
| 416 | 426 | .subcommand( |
| 417 | 427 | SubCommand::with_name("read") |
| 418 | 428 | .about("Mark the current room as read."), |
| 429 | ) | |
| 430 | .subcommand( | |
| 431 | SubCommand::with_name("version") | |
| 432 | .about("Show version information about weechat-matrix."), | |
| 419 | 433 | ); |
| 420 | 434 | |
| 421 | 435 | parse_and_run(argparse, arguments, |args| self.run(buffer, args)); |