Skip to content

Commit

Permalink
Switch to external crate for printing version information.
Browse files Browse the repository at this point in the history
  • Loading branch information
mbfm committed Dec 9, 2024
1 parent 72384ef commit 04b5da3
Show file tree
Hide file tree
Showing 18 changed files with 40 additions and 67 deletions.
12 changes: 12 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ rustls = { version = "*", default-features = false, features = ["ring"] }
serde = { version = "1.0.204", default-features = false }
serde_json = "1.0.111"
serde-spdx = "0.9.1"
shadow-formatted-version = "0.1.0"
shadow-rs = { version = "0.35.2", default-features = false }
sha1 = "0.10.6"
sha2 = "0.10.8"
Expand Down
3 changes: 2 additions & 1 deletion opendut-carl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ pin-project-lite = { workspace = true }
pq-sys = { workspace = true }
reqwest = { workspace = true, features = ["json"] }
serde = { workspace = true, features = ["derive"] }
serde_json = { workspace = true}
serde_json = { workspace = true }
shadow-formatted-version = { workspace = true }
shadow-rs = { workspace = true, default-features = true }
tar = { workspace = true }
tempfile = { workspace = true }
Expand Down
8 changes: 4 additions & 4 deletions opendut-carl/src/grpc/metadata_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ impl MetadataProvider for MetadataProviderFacade {

let reply = VersionResponse {
version_info: Some(VersionInfo {
name: String::from(crate::app_info::CRATE_VERSION),
revision: String::from(crate::app_info::REVISION),
revision_date: String::from(crate::app_info::REVISION_DATE),
build_date: String::from(crate::app_info::BUILD_DATE),
name: String::from(crate::app_info::PKG_VERSION),
revision: String::from(crate::app_info::COMMIT_HASH),
revision_date: String::from(crate::app_info::COMMIT_DATE),
build_date: String::from(crate::app_info::BUILD_TIME),
})
};

Expand Down
4 changes: 2 additions & 2 deletions opendut-carl/src/http/router/cleo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub async fn download_cleo(
Path(architecture): Path<CleoArch>,
State(carl_install_directory): State<CarlInstallDirectory>,
) -> impl IntoResponse {
let file_name = format!("{}-{}.tar.gz", &architecture.distribution_name(), crate::app_info::CRATE_VERSION);
let file_name = format!("{}-{}.tar.gz", &architecture.distribution_name(), crate::app_info::PKG_VERSION);
let file_path = carl_install_directory.path.join(CLEO_IDENTIFIER).join(&file_name);

let mut response = ServeFile::new_with_mime(file_path, &mime::APPLICATION_OCTET_STREAM)
Expand Down Expand Up @@ -51,7 +51,7 @@ mod test {
let dir = temp.child(CLEO_IDENTIFIER);
fs::create_dir_all(&dir).expect("Unable to create dir.");

let file_name = format!("{}-{}.tar.gz", &CleoArch::X86_64.distribution_name(), crate::app_info::CRATE_VERSION);
let file_name = format!("{}-{}.tar.gz", &CleoArch::X86_64.distribution_name(), crate::app_info::PKG_VERSION);

let tar_file = dir.child(&file_name);
File::create(&tar_file)?;
Expand Down
4 changes: 2 additions & 2 deletions opendut-carl/src/http/router/edgar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub async fn download_edgar(
State(carl_install_directory): State<CarlInstallDirectory>,
) -> impl IntoResponse {

let file_name = format!("{}-{}.tar.gz", &architecture.distribution_name(), crate::app_info::CRATE_VERSION);
let file_name = format!("{}-{}.tar.gz", &architecture.distribution_name(), crate::app_info::PKG_VERSION);
let edgar_path = carl_install_directory.path.join(EDGAR_IDENTIFIER).join(&file_name);

let mut response = ServeFile::new_with_mime(edgar_path, &mime::APPLICATION_OCTET_STREAM)
Expand Down Expand Up @@ -50,7 +50,7 @@ mod test {
let dir = temp.child(EDGAR_IDENTIFIER);
fs::create_dir_all(&dir).expect("Unable to create dir.");

let file_name = format!("{}-{}.tar.gz", &EdgarArch::X86_64.distribution_name(), crate::app_info::CRATE_VERSION);
let file_name = format!("{}-{}.tar.gz", &EdgarArch::X86_64.distribution_name(), crate::app_info::PKG_VERSION);

let tar_file = dir.child(&file_name);
File::create(&tar_file)?;
Expand Down
2 changes: 1 addition & 1 deletion opendut-carl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use crate::startup::tls::TlsConfig;

pub mod grpc;
pub mod util;
opendut_util::app_info!();
shadow_rs::shadow!(app_info);

mod actions;
mod cluster;
Expand Down
6 changes: 5 additions & 1 deletion opendut-carl/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
use opendut_carl::app_info;

shadow_formatted_version::from_shadow!(app_info);

const BANNER: &str = r"
_____ _______
| __ \ |__ __|
Expand All @@ -16,7 +20,7 @@ const BANNER: &str = r"

#[tokio::main]
async fn main() -> anyhow::Result<()> {
println!("{}", opendut_carl::app_info::formatted_with_banner(BANNER));
println!("{BANNER}\n{version_info}", version_info=FORMATTED_VERSION);

opendut_carl::create_with_telemetry(opendut_util::settings::Config::default()).await
}
2 changes: 1 addition & 1 deletion opendut-carl/src/provisioning/cleo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub fn create_cleo_install_script(
) -> anyhow::Result<()> {

for arch in CleoArch::arch_iterator() {
let cleo_tar_file = carl_install_directory.join(CLEO_IDENTIFIER).join(format!("{}-{}.tar.gz", arch.distribution_name(), crate::app_info::CRATE_VERSION));
let cleo_tar_file = carl_install_directory.join(CLEO_IDENTIFIER).join(format!("{}-{}.tar.gz", arch.distribution_name(), crate::app_info::PKG_VERSION));
add_file_to_archive(
&ca,
&cleo_tar_file,
Expand Down
1 change: 1 addition & 0 deletions opendut-cleo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ glob = { workspace = true }
indoc = { workspace = true }
serde = { workspace = true, features = ["derive"] }
serde_json = { workspace = true }
shadow-formatted-version = { workspace = true }
shadow-rs = { workspace = true, default-features = true }
thiserror = { workspace = true }
tokio = { workspace = true, features = ["full"] }
Expand Down
5 changes: 3 additions & 2 deletions opendut-cleo/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ pub mod parse;
type Error = String;
type Result<T> = std::result::Result<T, Error>;

opendut_util::app_info!();
shadow_rs::shadow!(app_info);
shadow_formatted_version::from_shadow!(app_info);

/// CLEO is a command line tool to manage openDuT resources.
#[derive(Parser)]
#[command(author, about, long_about = None)]
#[command(long_version = crate::app_info::formatted())]
#[command(long_version = crate::FORMATTED_VERSION)]
struct Args {
#[command(subcommand)]
command: Commands,
Expand Down
1 change: 1 addition & 0 deletions opendut-edgar/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ regex = { workspace = true }
reqwest = { workspace = true }
rtnetlink = { workspace = true }
serde = { workspace = true, features = ["std", "derive"] }
shadow-formatted-version = { workspace = true }
shadow-rs = { workspace = true, default-features = true }
sha2 = { workspace = true }
sudo = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion opendut-edgar/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use opendut_util::project;
#[derive(Debug, Parser)]
#[command(name = "opendut-edgar")]
#[command(about = "Connect your ECU to openDuT.")]
#[command(long_version = crate::app_info::formatted())]
#[command(long_version = crate::FORMATTED_VERSION)]
struct Cli {
#[command(subcommand)]
command: Commands,
Expand Down
3 changes: 2 additions & 1 deletion opendut-edgar/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
opendut_util::app_info!();
shadow_rs::shadow!(app_info);
shadow_formatted_version::from_shadow!(app_info);

mod cli;
pub use cli::cli;
Expand Down
2 changes: 1 addition & 1 deletion opendut-edgar/src/service/start.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const BANNER: &str = r"
|______|_____/ \_____/_/ \_\_| \_\";

pub async fn launch(id_override: Option<PeerId>) -> anyhow::Result<()> {
println!("{}", crate::app_info::formatted_with_banner(BANNER));
println!("{BANNER}\n{version_info}", version_info=crate::FORMATTED_VERSION);

let settings_override = config::Config::builder()
.set_override_option(settings::key::peer::id, id_override.map(|id| id.to_string()))?
Expand Down
2 changes: 1 addition & 1 deletion opendut-edgar/src/setup/start.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ fn determine_service_user_name() -> User {
}

fn user_confirmation(dry_run: &DryRun) -> anyhow::Result<bool> {
let crate_version = crate::app_info::CRATE_VERSION;
let crate_version = crate::app_info::PKG_VERSION;
match dry_run {
DryRun::No => {
println!("This will setup EDGAR {crate_version} on your system.");
Expand Down
47 changes: 0 additions & 47 deletions opendut-util/src/app_info.rs

This file was deleted.

2 changes: 0 additions & 2 deletions opendut-util/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
pub mod app_info;

#[cfg(feature = "crypto")]
pub mod crypto;

Expand Down

0 comments on commit 04b5da3

Please sign in to comment.