← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~jugmac00/lpcraft:rename-output-option into lpcraft:main

 

Jürgen Gmach has proposed merging ~jugmac00/lpcraft:rename-output-option into lpcraft:main.

Commit message:
Improve output handling via CLI option

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~jugmac00/lpcraft/+git/lpcraft/+merge/415195

This change should also be reflected in buildd - though, thanks to argparse magic, buildd will work with the renamed option as is, see https://docs.python.org/3/library/argparse.html#argument-abbreviations-prefix-matching
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~jugmac00/lpcraft:rename-output-option into lpcraft:main.
diff --git a/README.rst b/README.rst
index aa700b3..14a00b4 100644
--- a/README.rst
+++ b/README.rst
@@ -23,5 +23,5 @@ more complete and stable, it will be made available from the snap store.)
 You can run ``lpcraft`` from a directory containing ``.launchpad.yaml``,
 although it won't do very much useful yet.
 
-To save the output from a job, use ``lpcraft run --output
+To save the output from a job, use ``lpcraft run --output-directory
 /path/to/output/directory``.
diff --git a/docs/index.rst b/docs/index.rst
index 84bdd04..b8cfbab 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -35,7 +35,7 @@ Example configuration
             output:
                 paths: [output]
 
-    $ lpcraft run --output out
+    $ lpcraft run --output-directory out
     Running the job
     $ cat out/test/focal/amd64/files/output
     hello world
diff --git a/lpcraft/commands/run.py b/lpcraft/commands/run.py
index bc0b7da..91fa7a1 100644
--- a/lpcraft/commands/run.py
+++ b/lpcraft/commands/run.py
@@ -282,7 +282,10 @@ def run(args: Namespace) -> int:
                     raise CommandError(f"No job definition for {job_name!r}")
                 for job in jobs:
                     _run_job(
-                        job_name, job, provider, getattr(args, "output", None)
+                        job_name,
+                        job,
+                        provider,
+                        getattr(args, "output_directory", None),
                     )
             except CommandError as e:
                 if len(stage) == 1:
diff --git a/lpcraft/commands/tests/test_run.py b/lpcraft/commands/tests/test_run.py
index 80998fc..4fae0e0 100644
--- a/lpcraft/commands/tests/test_run.py
+++ b/lpcraft/commands/tests/test_run.py
@@ -722,8 +722,9 @@ class TestRun(RunBaseTestCase):
         Path(".launchpad.yaml").write_text(config)
         Path("test_1.0.tar.gz").write_bytes(b"")
         Path("test_1.0.whl").write_bytes(b"")
-
-        result = self.run_command("run", "--output", str(target_path))
+        result = self.run_command(
+            "run", "--output-directory", str(target_path)
+        )
 
         self.assertEqual(0, result.exit_code)
         job_output = target_path / "build" / "focal" / "amd64"
@@ -782,7 +783,9 @@ class TestRun(RunBaseTestCase):
         )
         Path(".launchpad.yaml").write_text(config)
 
-        result = self.run_command("run", "--output", str(target_path))
+        result = self.run_command(
+            "run", "--output-directory", str(target_path)
+        )
 
         # The exact error message differs between Python 3.8 and 3.9, so
         # don't test it in detail, but make sure it includes the offending
@@ -825,7 +828,9 @@ class TestRun(RunBaseTestCase):
         Path(".launchpad.yaml").write_text(config)
         Path("symlink.txt").symlink_to("../target.txt")
 
-        result = self.run_command("run", "--output", str(target_path))
+        result = self.run_command(
+            "run", "--output-directory", str(target_path)
+        )
 
         # The exact error message differs between Python 3.8 and 3.9, so
         # don't test it in detail, but make sure it includes the offending
@@ -871,7 +876,9 @@ class TestRun(RunBaseTestCase):
         Path(".launchpad.yaml").write_text(config)
         Path("test_1.0.whl").write_bytes(b"")
 
-        result = self.run_command("run", "--output", str(target_path))
+        result = self.run_command(
+            "run", "--output-directory", str(target_path)
+        )
 
         self.assertThat(
             result,
@@ -914,7 +921,9 @@ class TestRun(RunBaseTestCase):
         )
         Path(".launchpad.yaml").write_text(config)
 
-        result = self.run_command("run", "--output", str(target_path))
+        result = self.run_command(
+            "run", "--output-directory", str(target_path)
+        )
 
         self.assertEqual(0, result.exit_code)
         job_output = target_path / "build" / "focal" / "amd64"
@@ -957,7 +966,9 @@ class TestRun(RunBaseTestCase):
         Path(".launchpad.yaml").write_text(config)
         Path("properties").write_text("version=0.1\n")
 
-        result = self.run_command("run", "--output", str(target_path))
+        result = self.run_command(
+            "run", "--output-directory", str(target_path)
+        )
 
         self.assertEqual(0, result.exit_code)
         job_output = target_path / "test" / "focal" / "amd64"
@@ -1005,7 +1016,9 @@ class TestRun(RunBaseTestCase):
             "version=0.2\nto-be-removed\nalready-missing\n"
         )
 
-        result = self.run_command("run", "--output", str(target_path))
+        result = self.run_command(
+            "run", "--output-directory", str(target_path)
+        )
 
         self.assertEqual(0, result.exit_code)
         job_output = target_path / "test" / "focal" / "amd64"
@@ -1047,7 +1060,9 @@ class TestRun(RunBaseTestCase):
         )
         Path(".launchpad.yaml").write_text(config)
 
-        result = self.run_command("run", "--output", str(target_path))
+        result = self.run_command(
+            "run", "--output-directory", str(target_path)
+        )
 
         # The exact error message differs between Python 3.8 and 3.9, so
         # don't test it in detail, but make sure it includes the offending
@@ -1090,7 +1105,9 @@ class TestRun(RunBaseTestCase):
         Path(".launchpad.yaml").write_text(config)
         Path("properties").symlink_to("../target")
 
-        result = self.run_command("run", "--output", str(target_path))
+        result = self.run_command(
+            "run", "--output-directory", str(target_path)
+        )
 
         # The exact error message differs between Python 3.8 and 3.9, so
         # don't test it in detail, but make sure it includes the offending
diff --git a/lpcraft/main.py b/lpcraft/main.py
index 16b24dd..8afe421 100644
--- a/lpcraft/main.py
+++ b/lpcraft/main.py
@@ -64,7 +64,9 @@ def main(argv: Optional[List[str]] = None) -> int:
 
     parser_run = subparsers.add_parser("run", help=run.__doc__)
     parser_run.add_argument(
-        "--output", type=Path, help="Write output files to this directory."
+        "--output-directory",
+        type=Path,
+        help="Write output files to this directory.",
     )
     parser_run.add_argument(
         "-c",
@@ -77,7 +79,9 @@ def main(argv: Optional[List[str]] = None) -> int:
 
     parser_run_one = subparsers.add_parser("run-one", help=run_one.__doc__)
     parser_run_one.add_argument(
-        "--output", type=Path, help="Write output files to this directory."
+        "--output-directory",
+        type=Path,
+        help="Write output files to this directory.",
     )
     parser_run_one.add_argument(
         "-c",