summaryrefslogtreecommitdiff
path: root/CommandLineWrapper
diff options
context:
space:
mode:
Diffstat (limited to 'CommandLineWrapper')
-rw-r--r--CommandLineWrapper/Constants.cs2
-rw-r--r--CommandLineWrapper/JVCSCommandInvoker.cs26
-rw-r--r--CommandLineWrapper/JVCSWorkspace.cs11
-rw-r--r--CommandLineWrapper/JsonResults/Implements/AccountListResult.cs5
-rw-r--r--CommandLineWrapper/JsonResults/Implements/HereResult.cs8
-rw-r--r--CommandLineWrapper/JsonResults/Implements/InfoResult.cs6
-rw-r--r--CommandLineWrapper/JsonResults/Implements/ShareListResult.cs5
-rw-r--r--CommandLineWrapper/JsonResults/Implements/ShareSeeResult.cs7
-rw-r--r--CommandLineWrapper/JsonResults/Implements/SheetAlignTasksResult.cs9
-rw-r--r--CommandLineWrapper/JsonResults/Implements/SheetListResult.cs5
-rw-r--r--CommandLineWrapper/JsonResults/Implements/StatusResult.cs3
-rw-r--r--CommandLineWrapper/JsonResults/JsonResultGetter.cs4
-rw-r--r--CommandLineWrapper/WorkspaceCommandGenerator/Program.cs4
13 files changed, 50 insertions, 45 deletions
diff --git a/CommandLineWrapper/Constants.cs b/CommandLineWrapper/Constants.cs
index 91d0bd8..cf03242 100644
--- a/CommandLineWrapper/Constants.cs
+++ b/CommandLineWrapper/Constants.cs
@@ -3,7 +3,7 @@ namespace CommandLineWrapper;
public static class Constants
{
// Command line program path
- public static FileInfo CommandLinePath => new FileInfo(
+ public static FileInfo CommandLinePath => new(
Path.Combine(AppDomain.CurrentDomain.BaseDirectory,
OperatingSystem.IsWindows() ? "JustEnoughVCS.exe" : "JustEnoughVCS")
);
diff --git a/CommandLineWrapper/JVCSCommandInvoker.cs b/CommandLineWrapper/JVCSCommandInvoker.cs
index 56d67ca..3d4e594 100644
--- a/CommandLineWrapper/JVCSCommandInvoker.cs
+++ b/CommandLineWrapper/JVCSCommandInvoker.cs
@@ -1,5 +1,6 @@
using System.Diagnostics;
-using CommandLineWrapper;
+
+namespace CommandLineWrapper;
public static class JVCSCommandInvoker
{
@@ -25,17 +26,16 @@ public static class JVCSCommandInvoker
if (!string.IsNullOrEmpty(workingDirectory))
startInfo.WorkingDirectory = workingDirectory;
- using (var process = new Process { StartInfo = startInfo })
- {
- process.Start();
- string output = await process.StandardOutput.ReadToEndAsync();
- await process.WaitForExitAsync();
+ using var process = new Process();
+ process.StartInfo = startInfo;
+ process.Start();
+ string output = await process.StandardOutput.ReadToEndAsync();
+ await process.WaitForExitAsync();
- return new InvokeResult
- {
- ExitCode = process.ExitCode,
- StandardOutput = output.Trim()
- };
- }
+ return new InvokeResult
+ {
+ ExitCode = process.ExitCode,
+ StandardOutput = output.Trim()
+ };
}
-}
+} \ No newline at end of file
diff --git a/CommandLineWrapper/JVCSWorkspace.cs b/CommandLineWrapper/JVCSWorkspace.cs
index d88209c..8afd212 100644
--- a/CommandLineWrapper/JVCSWorkspace.cs
+++ b/CommandLineWrapper/JVCSWorkspace.cs
@@ -1,10 +1,12 @@
-using CommandLineWrapper;
+namespace CommandLineWrapper;
public class JVCSWorkspace
{
public string WorkspaceDirectory => _workspaceDirectory ?? Directory.GetCurrentDirectory();
+ public bool SuccessInitialized => _successInitialized;
private string? _workspaceDirectory;
+ private bool _successInitialized;
public async Task InitializeAsync(string directory)
{
@@ -17,15 +19,18 @@ public class JVCSWorkspace
var currentWorkspace = result.StandardOutput;
// Check if the obtained workspace directory is valid (not empty and exists)
- if (string.IsNullOrWhiteSpace(currentWorkspace) &&
+ if (!string.IsNullOrWhiteSpace(currentWorkspace) &&
Directory.Exists(currentWorkspace))
{
_workspaceDirectory = currentWorkspace;
+ _successInitialized = true;
}
else
{
// If the workspace is invalid, initialize a new workspace
- await JVCSCommandInvoker.Invoke(Constants.CommandParameterGenerator.Initialize());
+ result = await JVCSCommandInvoker.Invoke(Constants.CommandParameterGenerator.Initialize(), directory);
+ if (result.ExitCode == 0)
+ _successInitialized = true;
}
}
}
diff --git a/CommandLineWrapper/JsonResults/Implements/AccountListResult.cs b/CommandLineWrapper/JsonResults/Implements/AccountListResult.cs
index 600b839..c6242ff 100644
--- a/CommandLineWrapper/JsonResults/Implements/AccountListResult.cs
+++ b/CommandLineWrapper/JsonResults/Implements/AccountListResult.cs
@@ -1,5 +1,4 @@
-using CommandLineWrapper;
-using CommandLineWrapper.JsonResults;
+namespace CommandLineWrapper.JsonResults.Implements;
public class AccountListResultGetter : JsonResultGetter<AccountListResult>
{
@@ -15,4 +14,4 @@ public struct AccountListResult
public struct AccountItem
{
public bool HasPrivateKey { get; set; }
-}
+} \ No newline at end of file
diff --git a/CommandLineWrapper/JsonResults/Implements/HereResult.cs b/CommandLineWrapper/JsonResults/Implements/HereResult.cs
index b3086a1..497d6c2 100644
--- a/CommandLineWrapper/JsonResults/Implements/HereResult.cs
+++ b/CommandLineWrapper/JsonResults/Implements/HereResult.cs
@@ -1,5 +1,4 @@
-using CommandLineWrapper;
-using CommandLineWrapper.JsonResults;
+namespace CommandLineWrapper.JsonResults.Implements;
public class HereResultGetter : JsonResultGetter<HereResult>
{
@@ -8,6 +7,9 @@ public class HereResultGetter : JsonResultGetter<HereResult>
public HereResultGetter(DirectoryInfo currentDirectory)
=> _currentDirectory = currentDirectory;
+ public void ChangeDirectory(DirectoryInfo directory)
+ => _currentDirectory = directory;
+
protected override Task<JVCSCommandInvoker.InvokeResult> ExecCommand(JVCSWorkspace workspace)
=> JVCSCommandInvoker.Invoke(Constants.CommandParameterGenerator.Here(), _currentDirectory.ToString());
}
@@ -27,4 +29,4 @@ public struct HereResultItem
public bool Exist { get; set; }
public bool Modified { get; set; }
public string Holder { get; set; }
-}
+} \ No newline at end of file
diff --git a/CommandLineWrapper/JsonResults/Implements/InfoResult.cs b/CommandLineWrapper/JsonResults/Implements/InfoResult.cs
index ecef724..1a3d11e 100644
--- a/CommandLineWrapper/JsonResults/Implements/InfoResult.cs
+++ b/CommandLineWrapper/JsonResults/Implements/InfoResult.cs
@@ -1,5 +1,4 @@
-using CommandLineWrapper;
-using CommandLineWrapper.JsonResults;
+namespace CommandLineWrapper.JsonResults.Implements;
public class InfoResultGetter : JsonResultGetter<InfoResult>
{
@@ -8,6 +7,9 @@ public class InfoResultGetter : JsonResultGetter<InfoResult>
public InfoResultGetter(string mappingName)
=> _mappingName = mappingName;
+ public void ChangeMappingName(string mappingName)
+ => _mappingName = mappingName;
+
protected override Task<JVCSCommandInvoker.InvokeResult> ExecCommand(JVCSWorkspace workspace)
=> workspace.Info(_mappingName);
}
diff --git a/CommandLineWrapper/JsonResults/Implements/ShareListResult.cs b/CommandLineWrapper/JsonResults/Implements/ShareListResult.cs
index 4736b81..f309f8c 100644
--- a/CommandLineWrapper/JsonResults/Implements/ShareListResult.cs
+++ b/CommandLineWrapper/JsonResults/Implements/ShareListResult.cs
@@ -1,5 +1,4 @@
-using CommandLineWrapper;
-using CommandLineWrapper.JsonResults;
+namespace CommandLineWrapper.JsonResults.Implements;
public class ShareListResultGetter : JsonResultGetter<ShareListResult>
{
@@ -18,4 +17,4 @@ public struct ShareItem
public string Sharer { get; set; }
public string Description { get; set; }
public int FileCount { get; set; }
-}
+} \ No newline at end of file
diff --git a/CommandLineWrapper/JsonResults/Implements/ShareSeeResult.cs b/CommandLineWrapper/JsonResults/Implements/ShareSeeResult.cs
index c965b25..0fc63ee 100644
--- a/CommandLineWrapper/JsonResults/Implements/ShareSeeResult.cs
+++ b/CommandLineWrapper/JsonResults/Implements/ShareSeeResult.cs
@@ -1,7 +1,7 @@
-using CommandLineWrapper;
-using CommandLineWrapper.JsonResults;
using System.Text.Json.Serialization;
+namespace CommandLineWrapper.JsonResults.Implements;
+
public class ShareSeeResultGetter : JsonResultGetter<SeeShareResult>
{
private string _shareId;
@@ -9,6 +9,9 @@ public class ShareSeeResultGetter : JsonResultGetter<SeeShareResult>
public ShareSeeResultGetter(string shareId)
=> _shareId = shareId;
+ public void ChangeShareId(string shareId)
+ => _shareId = shareId;
+
protected override Task<JVCSCommandInvoker.InvokeResult> ExecCommand(JVCSWorkspace workspace)
=> workspace.ShareSee(_shareId);
}
diff --git a/CommandLineWrapper/JsonResults/Implements/SheetAlignTasksResult.cs b/CommandLineWrapper/JsonResults/Implements/SheetAlignTasksResult.cs
index 5539d19..60d07f3 100644
--- a/CommandLineWrapper/JsonResults/Implements/SheetAlignTasksResult.cs
+++ b/CommandLineWrapper/JsonResults/Implements/SheetAlignTasksResult.cs
@@ -1,13 +1,12 @@
-using CommandLineWrapper;
-using CommandLineWrapper.JsonResults;
+namespace CommandLineWrapper.JsonResults.Implements;
-public class SheetAlignTasksResultGetter : JsonResultGetter<AlignJsonResult>
+public class SheetAlignTasksResultGetter : JsonResultGetter<AlignResult>
{
protected override Task<JVCSCommandInvoker.InvokeResult> ExecCommand(JVCSWorkspace workspace)
=> workspace.SheetAlignList();
}
-public struct AlignJsonResult
+public struct AlignResult
{
public Dictionary<string, AlignTaskMapping> AlignTasks { get; set; }
}
@@ -16,4 +15,4 @@ public struct AlignTaskMapping
{
public string LocalMapping { get; set; }
public string RemoteMapping { get; set; }
-}
+} \ No newline at end of file
diff --git a/CommandLineWrapper/JsonResults/Implements/SheetListResult.cs b/CommandLineWrapper/JsonResults/Implements/SheetListResult.cs
index 1fa9f0b..eb1068d 100644
--- a/CommandLineWrapper/JsonResults/Implements/SheetListResult.cs
+++ b/CommandLineWrapper/JsonResults/Implements/SheetListResult.cs
@@ -1,5 +1,4 @@
-using CommandLineWrapper;
-using CommandLineWrapper.JsonResults;
+namespace CommandLineWrapper.JsonResults.Implements;
public class SheetListResultGetter : JsonResultGetter<SheetListResult>
{
@@ -23,4 +22,4 @@ public struct SheetItem
{
public string Name { get; set; }
public string Holder { get; set; }
-}
+} \ No newline at end of file
diff --git a/CommandLineWrapper/JsonResults/Implements/StatusResult.cs b/CommandLineWrapper/JsonResults/Implements/StatusResult.cs
index aba2c25..6b52731 100644
--- a/CommandLineWrapper/JsonResults/Implements/StatusResult.cs
+++ b/CommandLineWrapper/JsonResults/Implements/StatusResult.cs
@@ -1,5 +1,4 @@
-using CommandLineWrapper;
-using CommandLineWrapper.JsonResults;
+namespace CommandLineWrapper.JsonResults.Implements;
public class StatusResultGetter : JsonResultGetter<StatusResult>
{
diff --git a/CommandLineWrapper/JsonResults/JsonResultGetter.cs b/CommandLineWrapper/JsonResults/JsonResultGetter.cs
index e1bf607..2afd10c 100644
--- a/CommandLineWrapper/JsonResults/JsonResultGetter.cs
+++ b/CommandLineWrapper/JsonResults/JsonResultGetter.cs
@@ -1,10 +1,8 @@
-using static JVCSCommandInvoker;
-
namespace CommandLineWrapper.JsonResults
{
public abstract class JsonResultGetter<TJsonFormat>
{
- protected abstract Task<InvokeResult> ExecCommand(JVCSWorkspace workspace);
+ protected abstract Task<JVCSCommandInvoker.InvokeResult> ExecCommand(JVCSWorkspace workspace);
public async Task<TJsonFormat?> Get(JVCSWorkspace workspace)
{
diff --git a/CommandLineWrapper/WorkspaceCommandGenerator/Program.cs b/CommandLineWrapper/WorkspaceCommandGenerator/Program.cs
index e0bf373..1840066 100644
--- a/CommandLineWrapper/WorkspaceCommandGenerator/Program.cs
+++ b/CommandLineWrapper/WorkspaceCommandGenerator/Program.cs
@@ -1,7 +1,7 @@
using System.Text;
using System.Text.RegularExpressions;
-namespace CommandLineWrapper.CodeGenerator
+namespace CommandLineWrapper.WorkspaceCommandGenerator
{
class Program
{
@@ -114,7 +114,7 @@ namespace CommandLineWrapper.CodeGenerator
var sb = new StringBuilder();
// Add using statements and namespace
- sb.AppendLine("using static JVCSCommandInvoker;");
+ sb.AppendLine("using static CommandLineWrapper.JVCSCommandInvoker;");
sb.AppendLine();
sb.AppendLine("namespace CommandLineWrapper");
sb.AppendLine("{");