Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions src/poetry_plugin_export/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class ExportCommand(GroupCommand):
"Include development dependencies. (<warning>Deprecated</warning>)",
),
*GroupCommand._group_dependency_options(),
option("all-groups", None, "Include all sets of extra groups"),
option(
"extras",
"E",
Expand Down Expand Up @@ -92,7 +93,6 @@ def handle(self) -> int:
"</warning>"
)

# Checking extras
if self.option("extras") and self.option("all-extras"):
self.line_error(
"<error>You cannot specify explicit"
Expand All @@ -116,8 +116,22 @@ def handle(self) -> int:
f"Extra [{', '.join(sorted(invalid_extras))}] is not specified."
)

if self.option("with") and self.option("all-groups"):
self.line_error(
"<error>You cannot specify explicit"
" `<fg=yellow;options=bold>--with</>` while exporting"
" using `<fg=yellow;options=bold>--all-groups</>`.</error>"
)
return 1

groups = (
self.poetry.package.dependency_group_names(include_optional=True)
if self.option("all-groups")
else self.activated_groups
)

exporter = Exporter(self.poetry, self.io)
exporter.only_groups(list(self.activated_groups))
exporter.only_groups(list(groups))
exporter.with_extras(list(extras))
exporter.with_hashes(not self.option("without-hashes"))
exporter.with_credentials(self.option("with-credentials"))
Expand Down
17 changes: 17 additions & 0 deletions tests/command/test_command_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,23 @@ def test_extras_conflicts_all_extras(tester: CommandTester, do_lock: None) -> No
)


def test_export_with_all_groups(tester: CommandTester, do_lock: None) -> None:
tester.execute("--format requirements.txt --all-groups")
output = tester.io.fetch_output()
assert f"baz==2.0.0 ; {MARKER_PY}" in output
assert f"opt==2.2.0 ; {MARKER_PY}" in output


def test_with_conflicts_all_groups(tester: CommandTester, do_lock: None) -> None:
tester.execute("--with=bar --all-groups")

assert tester.status_code == 1
assert (
"You cannot specify explicit `--with` while exporting using `--all-groups`.\n"
in tester.io.fetch_error()
)


def test_export_with_urls(
monkeypatch: MonkeyPatch, tester: CommandTester, poetry: Poetry
) -> None:
Expand Down