summaryrefslogtreecommitdiff
path: root/CommandLineWrapper/JVCSWorkspace.cs
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-01-09 23:48:17 +0800
committer魏曹先生 <1992414357@qq.com>2026-01-09 23:48:17 +0800
commit6dedba9e3cedf6463f25460eba84111d6a0bd0dd (patch)
tree4dcc6855ada5b28e20835ab60800c1028e505f7a /CommandLineWrapper/JVCSWorkspace.cs
parent6b9268d2d88c81c18f2cc21e343d321989dad99c (diff)
Add command line wrapper for JVCS operations
Diffstat (limited to 'CommandLineWrapper/JVCSWorkspace.cs')
-rw-r--r--CommandLineWrapper/JVCSWorkspace.cs35
1 files changed, 35 insertions, 0 deletions
diff --git a/CommandLineWrapper/JVCSWorkspace.cs b/CommandLineWrapper/JVCSWorkspace.cs
new file mode 100644
index 0000000..6a39bbf
--- /dev/null
+++ b/CommandLineWrapper/JVCSWorkspace.cs
@@ -0,0 +1,35 @@
+using CommandLineWrapper;
+
+public class JVCSWorkspace
+{
+ private string? _workspaceDirectory;
+
+ public async Task InitializeAsync(string directory)
+ {
+ // If the specified directory does not exist, create it
+ if (!Directory.Exists(directory))
+ Directory.CreateDirectory(directory);
+
+ // Invoke command to get workspace directory
+ var result = await JVCSCommandInvoker.Invoke(Constants.CommandParameterGenerator.GetWorkspaceDirectory(), directory);
+ var currentWorkspace = result.StandardOutput;
+
+ // Check if the obtained workspace directory is valid (not empty and exists)
+ if (string.IsNullOrWhiteSpace(currentWorkspace) &&
+ Directory.Exists(currentWorkspace))
+ {
+ _workspaceDirectory = currentWorkspace;
+ }
+ else
+ {
+ // If the workspace is invalid, initialize a new workspace
+ await JVCSCommandInvoker.Invoke(Constants.CommandParameterGenerator.Initialize());
+ }
+ }
+
+ // Login to a upstream vault
+ public async Task Login(string account, string upstream)
+ {
+ await JVCSCommandInvoker.Invoke(Constants.CommandParameterGenerator.Login(account, upstream));
+ }
+}