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
1diff --git a/README.rst b/README.rst
2index aa700b3..14a00b4 100644
3--- a/README.rst
4+++ b/README.rst
5@@ -23,5 +23,5 @@ more complete and stable, it will be made available from the snap store.)
6 You can run ``lpcraft`` from a directory containing ``.launchpad.yaml``,
7 although it won't do very much useful yet.
8
9-To save the output from a job, use ``lpcraft run --output
10+To save the output from a job, use ``lpcraft run --output-directory
11 /path/to/output/directory``.
12diff --git a/docs/index.rst b/docs/index.rst
13index 84bdd04..b8cfbab 100644
14--- a/docs/index.rst
15+++ b/docs/index.rst
16@@ -35,7 +35,7 @@ Example configuration
17 output:
18 paths: [output]
19
20- $ lpcraft run --output out
21+ $ lpcraft run --output-directory out
22 Running the job
23 $ cat out/test/focal/amd64/files/output
24 hello world
25diff --git a/lpcraft/commands/run.py b/lpcraft/commands/run.py
26index bc0b7da..91fa7a1 100644
27--- a/lpcraft/commands/run.py
28+++ b/lpcraft/commands/run.py
29@@ -282,7 +282,10 @@ def run(args: Namespace) -> int:
30 raise CommandError(f"No job definition for {job_name!r}")
31 for job in jobs:
32 _run_job(
33- job_name, job, provider, getattr(args, "output", None)
34+ job_name,
35+ job,
36+ provider,
37+ getattr(args, "output_directory", None),
38 )
39 except CommandError as e:
40 if len(stage) == 1:
41diff --git a/lpcraft/commands/tests/test_run.py b/lpcraft/commands/tests/test_run.py
42index 80998fc..4fae0e0 100644
43--- a/lpcraft/commands/tests/test_run.py
44+++ b/lpcraft/commands/tests/test_run.py
45@@ -722,8 +722,9 @@ class TestRun(RunBaseTestCase):
46 Path(".launchpad.yaml").write_text(config)
47 Path("test_1.0.tar.gz").write_bytes(b"")
48 Path("test_1.0.whl").write_bytes(b"")
49-
50- result = self.run_command("run", "--output", str(target_path))
51+ result = self.run_command(
52+ "run", "--output-directory", str(target_path)
53+ )
54
55 self.assertEqual(0, result.exit_code)
56 job_output = target_path / "build" / "focal" / "amd64"
57@@ -782,7 +783,9 @@ class TestRun(RunBaseTestCase):
58 )
59 Path(".launchpad.yaml").write_text(config)
60
61- result = self.run_command("run", "--output", str(target_path))
62+ result = self.run_command(
63+ "run", "--output-directory", str(target_path)
64+ )
65
66 # The exact error message differs between Python 3.8 and 3.9, so
67 # don't test it in detail, but make sure it includes the offending
68@@ -825,7 +828,9 @@ class TestRun(RunBaseTestCase):
69 Path(".launchpad.yaml").write_text(config)
70 Path("symlink.txt").symlink_to("../target.txt")
71
72- result = self.run_command("run", "--output", str(target_path))
73+ result = self.run_command(
74+ "run", "--output-directory", str(target_path)
75+ )
76
77 # The exact error message differs between Python 3.8 and 3.9, so
78 # don't test it in detail, but make sure it includes the offending
79@@ -871,7 +876,9 @@ class TestRun(RunBaseTestCase):
80 Path(".launchpad.yaml").write_text(config)
81 Path("test_1.0.whl").write_bytes(b"")
82
83- result = self.run_command("run", "--output", str(target_path))
84+ result = self.run_command(
85+ "run", "--output-directory", str(target_path)
86+ )
87
88 self.assertThat(
89 result,
90@@ -914,7 +921,9 @@ class TestRun(RunBaseTestCase):
91 )
92 Path(".launchpad.yaml").write_text(config)
93
94- result = self.run_command("run", "--output", str(target_path))
95+ result = self.run_command(
96+ "run", "--output-directory", str(target_path)
97+ )
98
99 self.assertEqual(0, result.exit_code)
100 job_output = target_path / "build" / "focal" / "amd64"
101@@ -957,7 +966,9 @@ class TestRun(RunBaseTestCase):
102 Path(".launchpad.yaml").write_text(config)
103 Path("properties").write_text("version=0.1\n")
104
105- result = self.run_command("run", "--output", str(target_path))
106+ result = self.run_command(
107+ "run", "--output-directory", str(target_path)
108+ )
109
110 self.assertEqual(0, result.exit_code)
111 job_output = target_path / "test" / "focal" / "amd64"
112@@ -1005,7 +1016,9 @@ class TestRun(RunBaseTestCase):
113 "version=0.2\nto-be-removed\nalready-missing\n"
114 )
115
116- result = self.run_command("run", "--output", str(target_path))
117+ result = self.run_command(
118+ "run", "--output-directory", str(target_path)
119+ )
120
121 self.assertEqual(0, result.exit_code)
122 job_output = target_path / "test" / "focal" / "amd64"
123@@ -1047,7 +1060,9 @@ class TestRun(RunBaseTestCase):
124 )
125 Path(".launchpad.yaml").write_text(config)
126
127- result = self.run_command("run", "--output", str(target_path))
128+ result = self.run_command(
129+ "run", "--output-directory", str(target_path)
130+ )
131
132 # The exact error message differs between Python 3.8 and 3.9, so
133 # don't test it in detail, but make sure it includes the offending
134@@ -1090,7 +1105,9 @@ class TestRun(RunBaseTestCase):
135 Path(".launchpad.yaml").write_text(config)
136 Path("properties").symlink_to("../target")
137
138- result = self.run_command("run", "--output", str(target_path))
139+ result = self.run_command(
140+ "run", "--output-directory", str(target_path)
141+ )
142
143 # The exact error message differs between Python 3.8 and 3.9, so
144 # don't test it in detail, but make sure it includes the offending
145diff --git a/lpcraft/main.py b/lpcraft/main.py
146index 16b24dd..8afe421 100644
147--- a/lpcraft/main.py
148+++ b/lpcraft/main.py
149@@ -64,7 +64,9 @@ def main(argv: Optional[List[str]] = None) -> int:
150
151 parser_run = subparsers.add_parser("run", help=run.__doc__)
152 parser_run.add_argument(
153- "--output", type=Path, help="Write output files to this directory."
154+ "--output-directory",
155+ type=Path,
156+ help="Write output files to this directory.",
157 )
158 parser_run.add_argument(
159 "-c",
160@@ -77,7 +79,9 @@ def main(argv: Optional[List[str]] = None) -> int:
161
162 parser_run_one = subparsers.add_parser("run-one", help=run_one.__doc__)
163 parser_run_one.add_argument(
164- "--output", type=Path, help="Write output files to this directory."
165+ "--output-directory",
166+ type=Path,
167+ help="Write output files to this directory.",
168 )
169 parser_run_one.add_argument(
170 "-c",

Subscribers

People subscribed via source and target branches