Merge ~jugmac00/lpci:rename-output-option into lpci:main

Proposed by Jürgen Gmach
Status: Merged
Merged at revision: 7458215ae8ed7c79c5d4b12e742749b717d4d2bf
Proposed branch: ~jugmac00/lpci:rename-output-option
Merge into: lpci:main
Diff against target: 170 lines (+39/-15)
5 files modified
README.rst (+1/-1)
docs/index.rst (+1/-1)
lpcraft/commands/run.py (+4/-1)
lpcraft/commands/tests/test_run.py (+27/-10)
lpcraft/main.py (+6/-2)
Reviewer Review Type Date Requested Status
Colin Watson (community) Approve
Review via email: mp+415195@code.launchpad.net

Commit message

Improve output handling via CLI option

Description of the change

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

To post a comment you must log in.
Revision history for this message
Colin Watson (cjwatson) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
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.)
23You can run ``lpcraft`` from a directory containing ``.launchpad.yaml``,23You can run ``lpcraft`` from a directory containing ``.launchpad.yaml``,
24although it won't do very much useful yet.24although it won't do very much useful yet.
2525
26To save the output from a job, use ``lpcraft run --output26To save the output from a job, use ``lpcraft run --output-directory
27/path/to/output/directory``.27/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
35 output:35 output:
36 paths: [output]36 paths: [output]
3737
38 $ lpcraft run --output out38 $ lpcraft run --output-directory out
39 Running the job39 Running the job
40 $ cat out/test/focal/amd64/files/output40 $ cat out/test/focal/amd64/files/output
41 hello world41 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:
282 raise CommandError(f"No job definition for {job_name!r}")282 raise CommandError(f"No job definition for {job_name!r}")
283 for job in jobs:283 for job in jobs:
284 _run_job(284 _run_job(
285 job_name, job, provider, getattr(args, "output", None)285 job_name,
286 job,
287 provider,
288 getattr(args, "output_directory", None),
286 )289 )
287 except CommandError as e:290 except CommandError as e:
288 if len(stage) == 1:291 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):
722 Path(".launchpad.yaml").write_text(config)722 Path(".launchpad.yaml").write_text(config)
723 Path("test_1.0.tar.gz").write_bytes(b"")723 Path("test_1.0.tar.gz").write_bytes(b"")
724 Path("test_1.0.whl").write_bytes(b"")724 Path("test_1.0.whl").write_bytes(b"")
725725 result = self.run_command(
726 result = self.run_command("run", "--output", str(target_path))726 "run", "--output-directory", str(target_path)
727 )
727728
728 self.assertEqual(0, result.exit_code)729 self.assertEqual(0, result.exit_code)
729 job_output = target_path / "build" / "focal" / "amd64"730 job_output = target_path / "build" / "focal" / "amd64"
@@ -782,7 +783,9 @@ class TestRun(RunBaseTestCase):
782 )783 )
783 Path(".launchpad.yaml").write_text(config)784 Path(".launchpad.yaml").write_text(config)
784785
785 result = self.run_command("run", "--output", str(target_path))786 result = self.run_command(
787 "run", "--output-directory", str(target_path)
788 )
786789
787 # The exact error message differs between Python 3.8 and 3.9, so790 # The exact error message differs between Python 3.8 and 3.9, so
788 # don't test it in detail, but make sure it includes the offending791 # don't test it in detail, but make sure it includes the offending
@@ -825,7 +828,9 @@ class TestRun(RunBaseTestCase):
825 Path(".launchpad.yaml").write_text(config)828 Path(".launchpad.yaml").write_text(config)
826 Path("symlink.txt").symlink_to("../target.txt")829 Path("symlink.txt").symlink_to("../target.txt")
827830
828 result = self.run_command("run", "--output", str(target_path))831 result = self.run_command(
832 "run", "--output-directory", str(target_path)
833 )
829834
830 # The exact error message differs between Python 3.8 and 3.9, so835 # The exact error message differs between Python 3.8 and 3.9, so
831 # don't test it in detail, but make sure it includes the offending836 # don't test it in detail, but make sure it includes the offending
@@ -871,7 +876,9 @@ class TestRun(RunBaseTestCase):
871 Path(".launchpad.yaml").write_text(config)876 Path(".launchpad.yaml").write_text(config)
872 Path("test_1.0.whl").write_bytes(b"")877 Path("test_1.0.whl").write_bytes(b"")
873878
874 result = self.run_command("run", "--output", str(target_path))879 result = self.run_command(
880 "run", "--output-directory", str(target_path)
881 )
875882
876 self.assertThat(883 self.assertThat(
877 result,884 result,
@@ -914,7 +921,9 @@ class TestRun(RunBaseTestCase):
914 )921 )
915 Path(".launchpad.yaml").write_text(config)922 Path(".launchpad.yaml").write_text(config)
916923
917 result = self.run_command("run", "--output", str(target_path))924 result = self.run_command(
925 "run", "--output-directory", str(target_path)
926 )
918927
919 self.assertEqual(0, result.exit_code)928 self.assertEqual(0, result.exit_code)
920 job_output = target_path / "build" / "focal" / "amd64"929 job_output = target_path / "build" / "focal" / "amd64"
@@ -957,7 +966,9 @@ class TestRun(RunBaseTestCase):
957 Path(".launchpad.yaml").write_text(config)966 Path(".launchpad.yaml").write_text(config)
958 Path("properties").write_text("version=0.1\n")967 Path("properties").write_text("version=0.1\n")
959968
960 result = self.run_command("run", "--output", str(target_path))969 result = self.run_command(
970 "run", "--output-directory", str(target_path)
971 )
961972
962 self.assertEqual(0, result.exit_code)973 self.assertEqual(0, result.exit_code)
963 job_output = target_path / "test" / "focal" / "amd64"974 job_output = target_path / "test" / "focal" / "amd64"
@@ -1005,7 +1016,9 @@ class TestRun(RunBaseTestCase):
1005 "version=0.2\nto-be-removed\nalready-missing\n"1016 "version=0.2\nto-be-removed\nalready-missing\n"
1006 )1017 )
10071018
1008 result = self.run_command("run", "--output", str(target_path))1019 result = self.run_command(
1020 "run", "--output-directory", str(target_path)
1021 )
10091022
1010 self.assertEqual(0, result.exit_code)1023 self.assertEqual(0, result.exit_code)
1011 job_output = target_path / "test" / "focal" / "amd64"1024 job_output = target_path / "test" / "focal" / "amd64"
@@ -1047,7 +1060,9 @@ class TestRun(RunBaseTestCase):
1047 )1060 )
1048 Path(".launchpad.yaml").write_text(config)1061 Path(".launchpad.yaml").write_text(config)
10491062
1050 result = self.run_command("run", "--output", str(target_path))1063 result = self.run_command(
1064 "run", "--output-directory", str(target_path)
1065 )
10511066
1052 # The exact error message differs between Python 3.8 and 3.9, so1067 # The exact error message differs between Python 3.8 and 3.9, so
1053 # don't test it in detail, but make sure it includes the offending1068 # don't test it in detail, but make sure it includes the offending
@@ -1090,7 +1105,9 @@ class TestRun(RunBaseTestCase):
1090 Path(".launchpad.yaml").write_text(config)1105 Path(".launchpad.yaml").write_text(config)
1091 Path("properties").symlink_to("../target")1106 Path("properties").symlink_to("../target")
10921107
1093 result = self.run_command("run", "--output", str(target_path))1108 result = self.run_command(
1109 "run", "--output-directory", str(target_path)
1110 )
10941111
1095 # The exact error message differs between Python 3.8 and 3.9, so1112 # The exact error message differs between Python 3.8 and 3.9, so
1096 # don't test it in detail, but make sure it includes the offending1113 # 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:
6464
65 parser_run = subparsers.add_parser("run", help=run.__doc__)65 parser_run = subparsers.add_parser("run", help=run.__doc__)
66 parser_run.add_argument(66 parser_run.add_argument(
67 "--output", type=Path, help="Write output files to this directory."67 "--output-directory",
68 type=Path,
69 help="Write output files to this directory.",
68 )70 )
69 parser_run.add_argument(71 parser_run.add_argument(
70 "-c",72 "-c",
@@ -77,7 +79,9 @@ def main(argv: Optional[List[str]] = None) -> int:
7779
78 parser_run_one = subparsers.add_parser("run-one", help=run_one.__doc__)80 parser_run_one = subparsers.add_parser("run-one", help=run_one.__doc__)
79 parser_run_one.add_argument(81 parser_run_one.add_argument(
80 "--output", type=Path, help="Write output files to this directory."82 "--output-directory",
83 type=Path,
84 help="Write output files to this directory.",
81 )85 )
82 parser_run_one.add_argument(86 parser_run_one.add_argument(
83 "-c",87 "-c",

Subscribers

People subscribed via source and target branches