summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bin/jv.rs39
-rw-r--r--src/bin/jvv.rs36
-rw-r--r--src/data.rs2
-rw-r--r--src/data/compile_info.rs.template20
-rw-r--r--src/lib.rs3
5 files changed, 96 insertions, 4 deletions
diff --git a/src/bin/jv.rs b/src/bin/jv.rs
index b7eb105..8ccd843 100644
--- a/src/bin/jv.rs
+++ b/src/bin/jv.rs
@@ -30,8 +30,11 @@ use just_enough_vcs::{
utils::tcp_connection::error::TcpTargetError,
vcs::{actions::local_actions::proc_set_upstream_vault_action, registry::client_registry},
};
-use just_enough_vcs_cli::utils::{
- input::confirm_hint_or, lang_selector::current_locales, md_colored::md, socket_addr_helper,
+use just_enough_vcs_cli::{
+ data::compile_info::CompileInfo,
+ utils::{
+ input::confirm_hint_or, lang_selector::current_locales, md_colored::md, socket_addr_helper,
+ },
};
use rust_i18n::{set_locale, t};
use tokio::{fs, net::TcpSocket};
@@ -54,6 +57,11 @@ struct JustEnoughVcsWorkspace {
#[derive(Subcommand, Debug)]
enum JustEnoughVcsWorkspaceCommand {
+ /// Version information
+ #[command(alias = "--version", alias = "-v")]
+ Version(VersionArgs),
+
+ /// Display help information
#[command(alias = "--help", alias = "-h")]
Help,
@@ -130,6 +138,12 @@ enum JustEnoughVcsWorkspaceCommand {
Sheets,
}
+#[derive(Parser, Debug)]
+struct VersionArgs {
+ #[arg(short = 'C', long = "compile-info")]
+ compile_info: bool,
+}
+
#[derive(Subcommand, Debug)]
enum AccountManage {
/// Show help information
@@ -407,6 +421,27 @@ async fn main() {
};
match parser.command {
+ JustEnoughVcsWorkspaceCommand::Version(version_args) => {
+ let compile_info = CompileInfo::default();
+ println!(
+ "{}",
+ md(t!("jv.version.header", version = compile_info.cli_version))
+ );
+
+ if version_args.compile_info {
+ println!(
+ "\n{}",
+ md(t!(
+ "jv.version.compile_info",
+ build_time = compile_info.date,
+ build_target = compile_info.target,
+ build_platform = compile_info.platform,
+ build_toolchain = compile_info.toolchain
+ ))
+ );
+ }
+ }
+
JustEnoughVcsWorkspaceCommand::Help => {
println!("{}", md(t!("jv.help")));
}
diff --git a/src/bin/jvv.rs b/src/bin/jvv.rs
index 8480029..8dc9c88 100644
--- a/src/bin/jvv.rs
+++ b/src/bin/jvv.rs
@@ -16,8 +16,9 @@ use just_enough_vcs::{
},
},
};
-use just_enough_vcs_cli::utils::{
- build_env_logger::build_env_logger, lang_selector::current_locales, md_colored::md,
+use just_enough_vcs_cli::{
+ data::compile_info::CompileInfo,
+ utils::{build_env_logger::build_env_logger, lang_selector::current_locales, md_colored::md},
};
use log::{error, info};
use rust_i18n::{set_locale, t};
@@ -40,6 +41,10 @@ struct JustEnoughVcsVault {
#[derive(Subcommand, Debug)]
enum JustEnoughVcsVaultCommand {
+ /// Version information
+ #[command(alias = "--version", alias = "-v")]
+ Version(VersionArgs),
+
/// Get vault info in the current directory
#[command(alias = "-H")]
Here(HereArgs),
@@ -65,6 +70,12 @@ enum JustEnoughVcsVaultCommand {
ServiceListen(ListenArgs),
}
+#[derive(Parser, Debug)]
+struct VersionArgs {
+ #[arg(short = 'C', long = "compile-info")]
+ compile_info: bool,
+}
+
#[derive(Subcommand, Debug)]
enum MemberManage {
/// Register a member to the vault
@@ -178,6 +189,27 @@ async fn main() {
};
match parser.command {
+ JustEnoughVcsVaultCommand::Version(version_args) => {
+ let compile_info = CompileInfo::default();
+ println!(
+ "{}",
+ md(t!("jvv.version.header", version = compile_info.cli_version))
+ );
+
+ if version_args.compile_info {
+ println!(
+ "\n{}",
+ md(t!(
+ "jvv.version.compile_info",
+ build_time = compile_info.date,
+ build_target = compile_info.target,
+ build_platform = compile_info.platform,
+ build_toolchain = compile_info.toolchain
+ ))
+ );
+ }
+ }
+
JustEnoughVcsVaultCommand::Here(here_args) => {
if here_args.help {
println!("{}", md(t!("jvv.here")));
diff --git a/src/data.rs b/src/data.rs
new file mode 100644
index 0000000..036fd98
--- /dev/null
+++ b/src/data.rs
@@ -0,0 +1,2 @@
+#[allow(dead_code)]
+pub mod compile_info;
diff --git a/src/data/compile_info.rs.template b/src/data/compile_info.rs.template
new file mode 100644
index 0000000..7720d2b
--- /dev/null
+++ b/src/data/compile_info.rs.template
@@ -0,0 +1,20 @@
+pub struct CompileInfo {
+ pub date: String,
+ pub target: String,
+ pub platform: String,
+ pub toolchain: String,
+
+ pub cli_version: String,
+}
+
+impl Default for CompileInfo {
+ fn default() -> Self {
+ Self {
+ date: "{date}".to_string(),
+ target: "{target}".to_string(),
+ platform: "{platform}".to_string(),
+ toolchain: "{toolchain}".to_string(),
+ cli_version: "{version}".to_string(),
+ }
+ }
+}
diff --git a/src/lib.rs b/src/lib.rs
index 4083028..8b39dd7 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,2 +1,5 @@
/// Utils
pub mod utils;
+
+/// Data
+pub mod data;