summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2025-11-17 17:42:36 +0800
committer魏曹先生 <1992414357@qq.com>2025-11-17 17:42:36 +0800
commit1804e265b4b096bc1c2eb08869e33299ff11e93c (patch)
treea68cbd24a4e221b64e213c3584fbc384a4d596e4 /src/bin
parent2fc64079167a08f41fe4900ce3a3dbd703e2c7a6 (diff)
Add login command combining account setup and vault connection
The new `jv login` command streamlines the process of setting up a workspace by combining account selection, vault connection, and initial sync into a single operation. - Add completion support for login command - Update help documentation in both English and Chinese - Add confirmation prompt for login operation
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/jv.rs72
1 files changed, 72 insertions, 0 deletions
diff --git a/src/bin/jv.rs b/src/bin/jv.rs
index 0fcd7d5..e8e3c64 100644
--- a/src/bin/jv.rs
+++ b/src/bin/jv.rs
@@ -180,6 +180,14 @@ enum JustEnoughVcsWorkspaceCommand {
/// Drop a sheet
Drop(SheetDropArgs),
+
+ /// As Member, Direct, and Update
+ #[command(alias = "signin")]
+ Login(LoginArgs),
+
+ // Completion Helpers
+ #[command(name = "_ip_history")]
+ HistoryIpAddress,
}
#[derive(Parser, Debug)]
@@ -302,6 +310,23 @@ struct SheetDropArgs {
}
#[derive(Parser, Debug)]
+struct LoginArgs {
+ /// Show help information
+ #[arg(short, long)]
+ help: bool,
+
+ /// Whether to skip confirmation
+ #[arg(short = 'C', long)]
+ confirm: bool,
+
+ /// Member ID
+ login_member_id: MemberId,
+
+ /// Upstream
+ upstream: String,
+}
+
+#[derive(Parser, Debug)]
struct CreateWorkspaceArgs {
/// Show help information
#[arg(short, long)]
@@ -860,6 +885,53 @@ async fn main() {
JustEnoughVcsWorkspaceCommand::Drop(args) => {
jv_sheet_drop(args).await;
}
+ JustEnoughVcsWorkspaceCommand::Login(args) => {
+ if !args.confirm {
+ println!(
+ "{}",
+ t!(
+ "jv.confirm.login",
+ account = args.login_member_id,
+ upstream = args.upstream
+ )
+ .trim()
+ .yellow()
+ );
+ confirm_hint_or(t!("common.confirm"), || exit(1)).await;
+ }
+
+ let user_dir = match UserDirectory::current_doc_dir() {
+ Some(dir) => dir,
+ None => {
+ eprintln!("{}", t!("jv.fail.account.no_user_dir").red());
+ return;
+ }
+ };
+
+ jv_account_as(
+ user_dir,
+ SetLocalWorkspaceAccountArgs {
+ help: false,
+ account_name: args.login_member_id,
+ },
+ )
+ .await;
+
+ jv_direct(DirectArgs {
+ help: false,
+ upstream: Some(args.upstream.clone()),
+ confirm: true,
+ })
+ .await;
+
+ jv_update(UpdateArgs { help: false }).await;
+ }
+ JustEnoughVcsWorkspaceCommand::HistoryIpAddress => {
+ get_recent_ip_address()
+ .await
+ .iter()
+ .for_each(|ip| println!("{}", ip));
+ }
}
}