Skip to main content

prax_cli/commands/
version.rs

1//! `prax version` command - Display version information.
2
3use crate::error::CliResult;
4use crate::output::{self, kv};
5
6/// Package version
7const VERSION: &str = env!("CARGO_PKG_VERSION");
8
9/// Package name
10const NAME: &str = env!("CARGO_PKG_NAME");
11
12/// Run the version command
13pub async fn run() -> CliResult<()> {
14    output::logo();
15    output::newline();
16
17    kv("Version", VERSION);
18    kv("Package", NAME);
19    kv("Binary", "prax");
20
21    // Get Rust version
22    #[cfg(debug_assertions)]
23    let build_mode = "debug";
24    #[cfg(not(debug_assertions))]
25    let build_mode = "release";
26
27    kv("Build", build_mode);
28
29    // Features
30    let mut features = Vec::new();
31
32    #[cfg(feature = "postgres")]
33    features.push("postgres");
34
35    #[cfg(feature = "mysql")]
36    features.push("mysql");
37
38    #[cfg(feature = "sqlite")]
39    features.push("sqlite");
40
41    if features.is_empty() {
42        features.push("none");
43    }
44
45    kv("Features", &features.join(", "));
46
47    output::newline();
48
49    // Additional info
50    output::section("Components");
51    kv("prax-schema", env!("CARGO_PKG_VERSION"));
52    kv("prax-query", env!("CARGO_PKG_VERSION"));
53    kv("prax-codegen", env!("CARGO_PKG_VERSION"));
54    kv("prax-migrate", env!("CARGO_PKG_VERSION"));
55
56    output::newline();
57    output::dim("https://prax.dev");
58
59    Ok(())
60}