feat(cli): let a build name its own version
A nightly printed the same 19.0.0 as the release it followed, so a bug report could not say which one it came from. SOULSEEK_RS_VERSION at compile time replaces the crate version in --version, the TUI and the daemon status.
This commit is contained in:
@@ -34,11 +34,16 @@ Exit codes:
|
||||
0 success 2 usage/config 3 connect or login 4 no results
|
||||
5 timed out 6 transfer failed 7 session lost 1 unexpected error";
|
||||
|
||||
pub const VERSION: &str = match option_env!("SOULSEEK_RS_VERSION") {
|
||||
Some(version) => version,
|
||||
None => env!("CARGO_PKG_VERSION"),
|
||||
};
|
||||
|
||||
#[derive(Parser, Debug, Default)]
|
||||
#[command(
|
||||
name = "soulseek-rs",
|
||||
author,
|
||||
version,
|
||||
version = VERSION,
|
||||
about = "Soulseek client in Rust 🦀",
|
||||
long_about = "Soulseek client in Rust.\n\nRun without a subcommand for the \
|
||||
interactive TUI, or use a subcommand for a scriptable \
|
||||
|
||||
@@ -522,7 +522,7 @@ impl Daemon {
|
||||
fn identify(&self) -> AuthResult {
|
||||
AuthResult {
|
||||
protocol: PROTOCOL_VERSION,
|
||||
daemon_version: env!("CARGO_PKG_VERSION").to_string(),
|
||||
daemon_version: crate::cli::VERSION.to_string(),
|
||||
username: self.session.username(),
|
||||
}
|
||||
}
|
||||
@@ -532,7 +532,7 @@ impl Daemon {
|
||||
DaemonStatus {
|
||||
username: self.session.username(),
|
||||
server: self.server.clone(),
|
||||
daemon_version: env!("CARGO_PKG_VERSION").to_string(),
|
||||
daemon_version: crate::cli::VERSION.to_string(),
|
||||
protocol: PROTOCOL_VERSION,
|
||||
listen_port: self.session.listen_port(),
|
||||
shared_folders: folders,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use crate::cli::VERSION;
|
||||
use crate::models::DownloadEntry;
|
||||
use crate::ui::{
|
||||
BYTES_PER_MB, accent_style, dimmed_style, error_style,
|
||||
@@ -14,8 +15,6 @@ use ratatui::{
|
||||
use soulseek_rs::DownloadStatus;
|
||||
use std::fmt::Write as _;
|
||||
|
||||
const VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||
|
||||
/// Bytes transferred, bytes expected and combined speed across the downloads
|
||||
/// that are actually running — or `None` when none are, so the caller can hide
|
||||
/// the progress readout entirely.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use super::name_scroll::{column_width, end_offset, scroll_text};
|
||||
use crate::cli::VERSION;
|
||||
use crate::models::FileDisplayData;
|
||||
use crate::ui::{
|
||||
BYTES_PER_MB, HIGHLIGHT_SYMBOL, body_style, dimmed_style, format_bytes,
|
||||
@@ -13,8 +14,6 @@ use ratatui::{
|
||||
};
|
||||
use std::collections::HashSet;
|
||||
|
||||
const VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||
|
||||
// The file name and its folder share whatever width the fixed columns leave,
|
||||
// the name getting the larger part: it is what a search is after, and a
|
||||
// folder's tail is a scroll away.
|
||||
|
||||
Reference in New Issue
Block a user