From 83452b42fffd7b842128687392bc323c6a207d8b Mon Sep 17 00:00:00 2001
From: Emre Sahin <github@emresult.com>
Date: Wed, 8 Nov 2023 23:10:51 +0300
Subject: [PATCH] Update doc tests

---
 book/src/ref/xvc-pipeline-import.md |  6 -----
 book/src/ref/xvc-pipeline-new.md    | 38 ++++++++++++-----------------
 book/src/ref/xvc-pipeline-run.md    | 21 +++-------------
 lib/src/cli/mod.rs                  |  2 +-
 lib/src/error.rs                    |  4 ++-
 lib/src/lib.rs                      |  2 +-
 6 files changed, 24 insertions(+), 49 deletions(-)

diff --git a/book/src/ref/xvc-pipeline-import.md b/book/src/ref/xvc-pipeline-import.md
index 9f47d0a5a..783bb9580 100644
--- a/book/src/ref/xvc-pipeline-import.md
+++ b/book/src/ref/xvc-pipeline-import.md
@@ -249,12 +249,6 @@ This way you can edit and import similar pipelines with minor differences.
 
 ```console
 $ xvc pipeline import --pipeline-name another-pipeline --file pipeline.yaml
-? 2
-error: unexpected argument '--name' found
-
-Usage: xvc pipeline import [OPTIONS]
-
-For more information, try '--help'.
 
 ```
 
diff --git a/book/src/ref/xvc-pipeline-new.md b/book/src/ref/xvc-pipeline-new.md
index d7e1ad47e..23cbf4094 100644
--- a/book/src/ref/xvc-pipeline-new.md
+++ b/book/src/ref/xvc-pipeline-new.md
@@ -29,12 +29,6 @@ You can create a new pipeline with a name.
 
 ```console
 $ xvc pipeline new --pipeline-name my-pipeline
-? 2
-error: unexpected argument '--name' found
-
-Usage: xvc pipeline new [OPTIONS] --pipeline-name <PIPELINE_NAME>
-
-For more information, try '--help'.
 
 ```
 
@@ -42,11 +36,13 @@ By default it will run the commands in the repository root.
 
 ```console
 $ xvc pipeline list
-+---------+---------+
-| Name    | Run Dir |
-+===================+
-| default |         |
-+---------+---------+
++-------------+---------+
+| Name        | Run Dir |
++=======================+
+| default     |         |
+|-------------+---------|
+| my-pipeline |         |
++-------------+---------+
 
 ```
 
@@ -55,12 +51,6 @@ If you want to define a pipeline specific to a directory, you can set the workin
 ```console
 $ xvc-test-helper create-directory-tree --directories 1 --files 3  --seed 20230215
 $ xvc pipeline new --pipeline-name another-pipeline --workdir dir-0001
-? 2
-error: unexpected argument '--name' found
-
-Usage: xvc pipeline new [OPTIONS] --pipeline-name <PIPELINE_NAME>
-
-For more information, try '--help'.
 
 ```
 
@@ -68,10 +58,14 @@ The pipeline will run the commands in the specified directory.
 
 ```console
 $ xvc pipeline list
-+---------+---------+
-| Name    | Run Dir |
-+===================+
-| default |         |
-+---------+---------+
++------------------+----------+
+| Name             | Run Dir  |
++=============================+
+| default          |          |
+|------------------+----------|
+| my-pipeline      |          |
+|------------------+----------|
+| another-pipeline | dir-0001 |
++------------------+----------+
 
 ```
diff --git a/book/src/ref/xvc-pipeline-run.md b/book/src/ref/xvc-pipeline-run.md
index a47a29549..ed7502766 100644
--- a/book/src/ref/xvc-pipeline-run.md
+++ b/book/src/ref/xvc-pipeline-run.md
@@ -75,30 +75,15 @@ You can run a specific pipeline by specifying its name with `--name` option.
 
 ```console
 $ xvc pipeline new --pipeline-name my-pipeline
-? 2
-error: unexpected argument '--name' found
-
-Usage: xvc pipeline new [OPTIONS] --pipeline-name <PIPELINE_NAME>
-
-For more information, try '--help'.
 
 $ xvc pipeline --pipeline-name my-pipeline step new --step-name my-hello --command "echo 'hello from my-pipeline'"
-? 2
-error: unexpected argument '--name' found
-
-Usage: xvc pipeline [OPTIONS] <COMMAND>
-
-For more information, try '--help'.
 
 ```
 
 ```console
 $ xvc pipeline run --pipeline-name my-pipeline
-? 2
-error: unexpected argument '--name' found
-
-Usage: xvc pipeline run [OPTIONS]
-
-For more information, try '--help'.
+[OUT] [my-hello] hello from my-pipeline
+ 
+[DONE] my-hello (echo 'hello from my-pipeline')
 
 ```
diff --git a/lib/src/cli/mod.rs b/lib/src/cli/mod.rs
index 05425a93d..423d4f9f2 100644
--- a/lib/src/cli/mod.rs
+++ b/lib/src/cli/mod.rs
@@ -512,7 +512,7 @@ fn git_checkout_ref(
 
 /// This receives `xvc_root` ownership because as a final operation, it must drop the root to
 /// record the last entity counter before commit.
-fn handle_git_automation(
+pub fn handle_git_automation(
     output_snd: &XvcOutputSender,
     xvc_root: XvcRoot,
     to_branch: Option<&str>,
diff --git a/lib/src/error.rs b/lib/src/error.rs
index c1016b641..4f730b7d5 100644
--- a/lib/src/error.rs
+++ b/lib/src/error.rs
@@ -90,8 +90,10 @@ pub enum Error {
         #[from]
         source: serde_yaml::Error,
     },
-    #[error("[E2004] Requires xvc repository.")]
+
+    #[error("This command requires Xvc repository. Please use xvc init first.")]
     RequiresXvcRepository,
+
     #[error("I/O Error: {source}")]
     IoError {
         #[from]
diff --git a/lib/src/lib.rs b/lib/src/lib.rs
index 2b60897b6..8a0e45bed 100755
--- a/lib/src/lib.rs
+++ b/lib/src/lib.rs
@@ -18,7 +18,7 @@ pub use xvc_walker as walker;
 
 pub use xvc_logging::watch;
 
-pub use crate::error::Result;
+pub use crate::error::{Error, Result};
 
 /// Adds `xvc` as the first elements to `args` and calls [cli::dispatch] after parsing them.
 pub fn dispatch(args: Vec<&str>) -> Result<()> {