summaryrefslogtreecommitdiff
path: root/CommandLineWrapper/JsonResults/Implements
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-01-13 06:24:07 +0800
committer魏曹先生 <1992414357@qq.com>2026-01-13 06:24:07 +0800
commit7d59c15b0efd2aa5a27aef356a265f850a2e7e2f (patch)
tree16f30ff5a7d5d871f0358f792988f369cc532b45 /CommandLineWrapper/JsonResults/Implements
parentb202287c51438d64f769dd72c579664493ba9109 (diff)
Add JSON result getters for command outputs
Diffstat (limited to 'CommandLineWrapper/JsonResults/Implements')
-rw-r--r--CommandLineWrapper/JsonResults/Implements/AccountListResult.cs18
-rw-r--r--CommandLineWrapper/JsonResults/Implements/HereResult.cs30
-rw-r--r--CommandLineWrapper/JsonResults/Implements/InfoResult.cs30
-rw-r--r--CommandLineWrapper/JsonResults/Implements/ShareListResult.cs21
-rw-r--r--CommandLineWrapper/JsonResults/Implements/ShareSeeResult.cs37
-rw-r--r--CommandLineWrapper/JsonResults/Implements/SheetAlignTasksResult.cs19
-rw-r--r--CommandLineWrapper/JsonResults/Implements/SheetListResult.cs26
-rw-r--r--CommandLineWrapper/JsonResults/Implements/StatusResult.cs36
8 files changed, 217 insertions, 0 deletions
diff --git a/CommandLineWrapper/JsonResults/Implements/AccountListResult.cs b/CommandLineWrapper/JsonResults/Implements/AccountListResult.cs
new file mode 100644
index 0000000..600b839
--- /dev/null
+++ b/CommandLineWrapper/JsonResults/Implements/AccountListResult.cs
@@ -0,0 +1,18 @@
+using CommandLineWrapper;
+using CommandLineWrapper.JsonResults;
+
+public class AccountListResultGetter : JsonResultGetter<AccountListResult>
+{
+ protected override Task<JVCSCommandInvoker.InvokeResult> ExecCommand(JVCSWorkspace workspace)
+ => workspace.AccountList();
+}
+
+public struct AccountListResult
+{
+ public Dictionary<string, AccountItem> Result { get; set; }
+}
+
+public struct AccountItem
+{
+ public bool HasPrivateKey { get; set; }
+}
diff --git a/CommandLineWrapper/JsonResults/Implements/HereResult.cs b/CommandLineWrapper/JsonResults/Implements/HereResult.cs
new file mode 100644
index 0000000..b3086a1
--- /dev/null
+++ b/CommandLineWrapper/JsonResults/Implements/HereResult.cs
@@ -0,0 +1,30 @@
+using CommandLineWrapper;
+using CommandLineWrapper.JsonResults;
+
+public class HereResultGetter : JsonResultGetter<HereResult>
+{
+ private DirectoryInfo _currentDirectory;
+
+ public HereResultGetter(DirectoryInfo currentDirectory)
+ => _currentDirectory = currentDirectory;
+
+ protected override Task<JVCSCommandInvoker.InvokeResult> ExecCommand(JVCSWorkspace workspace)
+ => JVCSCommandInvoker.Invoke(Constants.CommandParameterGenerator.Here(), _currentDirectory.ToString());
+}
+
+public struct HereResult
+{
+ public List<HereResultItem> Items { get; set; }
+}
+
+public struct HereResultItem
+{
+ public string Mapping { get; set; }
+ public string Name { get; set; }
+ public string CurrentVersion { get; set; }
+ public long Size { get; set; }
+ public bool IsDir { get; set; }
+ public bool Exist { get; set; }
+ public bool Modified { get; set; }
+ public string Holder { get; set; }
+}
diff --git a/CommandLineWrapper/JsonResults/Implements/InfoResult.cs b/CommandLineWrapper/JsonResults/Implements/InfoResult.cs
new file mode 100644
index 0000000..ecef724
--- /dev/null
+++ b/CommandLineWrapper/JsonResults/Implements/InfoResult.cs
@@ -0,0 +1,30 @@
+using CommandLineWrapper;
+using CommandLineWrapper.JsonResults;
+
+public class InfoResultGetter : JsonResultGetter<InfoResult>
+{
+ private string _mappingName;
+
+ public InfoResultGetter(string mappingName)
+ => _mappingName = mappingName;
+
+ protected override Task<JVCSCommandInvoker.InvokeResult> ExecCommand(JVCSWorkspace workspace)
+ => workspace.Info(_mappingName);
+}
+
+public struct InfoResult
+{
+ public string Mapping { get; set; }
+ public string InRef { get; set; }
+ public string Vfid { get; set; }
+ public List<InfoHistory> Histories { get; set; }
+}
+
+public struct InfoHistory
+{
+ public string Version { get; set; }
+ public string VersionCreator { get; set; }
+ public string VersionDescription { get; set; }
+ public bool IsCurrentVersion { get; set; }
+ public bool IsRefVersion { get; set; }
+}
diff --git a/CommandLineWrapper/JsonResults/Implements/ShareListResult.cs b/CommandLineWrapper/JsonResults/Implements/ShareListResult.cs
new file mode 100644
index 0000000..4736b81
--- /dev/null
+++ b/CommandLineWrapper/JsonResults/Implements/ShareListResult.cs
@@ -0,0 +1,21 @@
+using CommandLineWrapper;
+using CommandLineWrapper.JsonResults;
+
+public class ShareListResultGetter : JsonResultGetter<ShareListResult>
+{
+ protected override Task<JVCSCommandInvoker.InvokeResult> ExecCommand(JVCSWorkspace workspace)
+ => workspace.ShareList();
+}
+
+public struct ShareListResult
+{
+ public List<ShareItem> ShareList { get; set; }
+}
+
+public struct ShareItem
+{
+ public string ShareId { get; set; }
+ public string Sharer { get; set; }
+ public string Description { get; set; }
+ public int FileCount { get; set; }
+}
diff --git a/CommandLineWrapper/JsonResults/Implements/ShareSeeResult.cs b/CommandLineWrapper/JsonResults/Implements/ShareSeeResult.cs
new file mode 100644
index 0000000..c965b25
--- /dev/null
+++ b/CommandLineWrapper/JsonResults/Implements/ShareSeeResult.cs
@@ -0,0 +1,37 @@
+using CommandLineWrapper;
+using CommandLineWrapper.JsonResults;
+using System.Text.Json.Serialization;
+
+public class ShareSeeResultGetter : JsonResultGetter<SeeShareResult>
+{
+ private string _shareId;
+
+ public ShareSeeResultGetter(string shareId)
+ => _shareId = shareId;
+
+ protected override Task<JVCSCommandInvoker.InvokeResult> ExecCommand(JVCSWorkspace workspace)
+ => workspace.ShareSee(_shareId);
+}
+
+public struct SeeShareResult
+{
+ public string ShareId { get; set; }
+ public string Sharer { get; set; }
+ public string Description { get; set; }
+ public Dictionary<string, SheetMappingMetadata> Mappings { get; set; }
+}
+
+public struct SheetMappingMetadata
+{
+ // TIPS
+ // Since SheetMappingMetadata in the serialized output of the command-line tool `jv sheet see <SHARE_ID>`
+ // comes directly from the version control repository,
+ // its property names use the original lowercase snake_case naming,
+ // so JsonPropertyName must be explicitly specified for mapping.
+
+ [JsonPropertyName("id")]
+ public string Id { get; set; }
+
+ [JsonPropertyName("ver")]
+ public string Version { get; set; }
+}
diff --git a/CommandLineWrapper/JsonResults/Implements/SheetAlignTasksResult.cs b/CommandLineWrapper/JsonResults/Implements/SheetAlignTasksResult.cs
new file mode 100644
index 0000000..5539d19
--- /dev/null
+++ b/CommandLineWrapper/JsonResults/Implements/SheetAlignTasksResult.cs
@@ -0,0 +1,19 @@
+using CommandLineWrapper;
+using CommandLineWrapper.JsonResults;
+
+public class SheetAlignTasksResultGetter : JsonResultGetter<AlignJsonResult>
+{
+ protected override Task<JVCSCommandInvoker.InvokeResult> ExecCommand(JVCSWorkspace workspace)
+ => workspace.SheetAlignList();
+}
+
+public struct AlignJsonResult
+{
+ public Dictionary<string, AlignTaskMapping> AlignTasks { get; set; }
+}
+
+public struct AlignTaskMapping
+{
+ public string LocalMapping { get; set; }
+ public string RemoteMapping { get; set; }
+}
diff --git a/CommandLineWrapper/JsonResults/Implements/SheetListResult.cs b/CommandLineWrapper/JsonResults/Implements/SheetListResult.cs
new file mode 100644
index 0000000..1fa9f0b
--- /dev/null
+++ b/CommandLineWrapper/JsonResults/Implements/SheetListResult.cs
@@ -0,0 +1,26 @@
+using CommandLineWrapper;
+using CommandLineWrapper.JsonResults;
+
+public class SheetListResultGetter : JsonResultGetter<SheetListResult>
+{
+ protected override Task<JVCSCommandInvoker.InvokeResult> ExecCommand(JVCSWorkspace workspace)
+ => workspace.SheetList();
+}
+
+public struct SheetListResult
+{
+ public SheetListJsonResult Result { get; set; }
+}
+
+public struct SheetListJsonResult
+{
+ public List<SheetItem> MySheets { get; set; }
+ public List<SheetItem> ReferenceSheets { get; set; }
+ public List<SheetItem> OtherSheets { get; set; }
+}
+
+public struct SheetItem
+{
+ public string Name { get; set; }
+ public string Holder { get; set; }
+}
diff --git a/CommandLineWrapper/JsonResults/Implements/StatusResult.cs b/CommandLineWrapper/JsonResults/Implements/StatusResult.cs
new file mode 100644
index 0000000..aba2c25
--- /dev/null
+++ b/CommandLineWrapper/JsonResults/Implements/StatusResult.cs
@@ -0,0 +1,36 @@
+using CommandLineWrapper;
+using CommandLineWrapper.JsonResults;
+
+public class StatusResultGetter : JsonResultGetter<StatusResult>
+{
+ protected override Task<JVCSCommandInvoker.InvokeResult> ExecCommand(JVCSWorkspace workspace)
+ => workspace.Status();
+}
+
+public struct StatusResult
+{
+ public List<string> Created { get; set; }
+ public List<string> Lost { get; set; }
+ public List<string> Erased { get; set; }
+ public List<MovedItem> Moved { get; set; }
+ public List<ModifiedItem> Modified { get; set; }
+}
+
+public enum ModifiedType
+{
+ Modified,
+ ModifiedButBaseVersionMismatch,
+ ModifiedButNotHeld,
+}
+
+public struct MovedItem
+{
+ public string From { get; set; }
+ public string To { get; set; }
+}
+
+public struct ModifiedItem
+{
+ public string Path { get; set; }
+ public ModifiedType ModificationType { get; set; }
+}