ricecoder_cli/commands/
version.rs1use super::Command;
4use crate::error::CliResult;
5use crate::output::OutputStyle;
6
7#[derive(Default)]
9pub struct VersionCommand;
10
11impl VersionCommand {
12 pub fn new() -> Self {
13 Self
14 }
15
16 fn get_version_info() -> String {
18 format!(
19 "RiceCoder v{}\n\nBuild Information:\n Edition: 2021\n Profile: {}\n Rust: {}",
20 env!("CARGO_PKG_VERSION"),
21 if cfg!(debug_assertions) {
22 "debug"
23 } else {
24 "release"
25 },
26 env!("CARGO_PKG_RUST_VERSION")
27 )
28 }
29}
30
31impl Command for VersionCommand {
32 fn execute(&self) -> CliResult<()> {
33 let style = OutputStyle::default();
34 println!("{}", style.header(&Self::get_version_info()));
35 Ok(())
36 }
37}