summaryrefslogtreecommitdiff
path: root/src/cmds/out
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-03-19 13:50:48 +0800
committer魏曹先生 <1992414357@qq.com>2026-03-19 13:50:48 +0800
commitf508de7bc4321db6f3dd71ea43c1cc384b7d6a7f (patch)
tree766f6cb4e4c1f9ad594426e6b618c406a429639d /src/cmds/out
parent74bc8902be593796eb6292151e08374072766e3e (diff)
Refactor workspace sheet command to use structured output
Diffstat (limited to 'src/cmds/out')
-rw-r--r--src/cmds/out/path.rs39
-rw-r--r--src/cmds/out/string_vcs.rs65
2 files changed, 104 insertions, 0 deletions
diff --git a/src/cmds/out/path.rs b/src/cmds/out/path.rs
new file mode 100644
index 0000000..2ddd643
--- /dev/null
+++ b/src/cmds/out/path.rs
@@ -0,0 +1,39 @@
+use serde::Serialize;
+use std::path::PathBuf;
+
+#[derive(Serialize)]
+pub struct JVPathOutput {
+ pub path: PathBuf,
+}
+
+impl From<PathBuf> for JVPathOutput {
+ fn from(path: PathBuf) -> Self {
+ JVPathOutput { path }
+ }
+}
+
+impl From<JVPathOutput> for PathBuf {
+ fn from(jv_path: JVPathOutput) -> Self {
+ jv_path.path
+ }
+}
+
+impl AsRef<PathBuf> for JVPathOutput {
+ fn as_ref(&self) -> &PathBuf {
+ &self.path
+ }
+}
+
+impl AsRef<std::path::Path> for JVPathOutput {
+ fn as_ref(&self) -> &std::path::Path {
+ &self.path
+ }
+}
+
+impl std::ops::Deref for JVPathOutput {
+ type Target = PathBuf;
+
+ fn deref(&self) -> &Self::Target {
+ &self.path
+ }
+}
diff --git a/src/cmds/out/string_vcs.rs b/src/cmds/out/string_vcs.rs
new file mode 100644
index 0000000..e01fde7
--- /dev/null
+++ b/src/cmds/out/string_vcs.rs
@@ -0,0 +1,65 @@
+use serde::Serialize;
+
+#[derive(Serialize)]
+pub struct JVStringVecOutput {
+ pub vec: Vec<String>,
+}
+
+impl From<Vec<String>> for JVStringVecOutput {
+ fn from(vec: Vec<String>) -> Self {
+ JVStringVecOutput { vec }
+ }
+}
+
+impl From<JVStringVecOutput> for Vec<String> {
+ fn from(jv_string_vec: JVStringVecOutput) -> Self {
+ jv_string_vec.vec
+ }
+}
+
+impl AsRef<Vec<String>> for JVStringVecOutput {
+ fn as_ref(&self) -> &Vec<String> {
+ &self.vec
+ }
+}
+
+impl AsRef<[String]> for JVStringVecOutput {
+ fn as_ref(&self) -> &[String] {
+ &self.vec
+ }
+}
+
+impl std::ops::Deref for JVStringVecOutput {
+ type Target = Vec<String>;
+
+ fn deref(&self) -> &Self::Target {
+ &self.vec
+ }
+}
+
+impl IntoIterator for JVStringVecOutput {
+ type Item = String;
+ type IntoIter = std::vec::IntoIter<String>;
+
+ fn into_iter(self) -> Self::IntoIter {
+ self.vec.into_iter()
+ }
+}
+
+impl<'a> IntoIterator for &'a JVStringVecOutput {
+ type Item = &'a String;
+ type IntoIter = std::slice::Iter<'a, String>;
+
+ fn into_iter(self) -> Self::IntoIter {
+ self.vec.iter()
+ }
+}
+
+impl<'a> IntoIterator for &'a mut JVStringVecOutput {
+ type Item = &'a mut String;
+ type IntoIter = std::slice::IterMut<'a, String>;
+
+ fn into_iter(self) -> Self::IntoIter {
+ self.vec.iter_mut()
+ }
+}