Skip to content

Commit

Permalink
add more checks for without and only, update message
Browse files Browse the repository at this point in the history
  • Loading branch information
Jiafi committed Aug 26, 2024
1 parent ac221d6 commit 6c6f677
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
1 change: 1 addition & 0 deletions docs/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,6 @@ poetry export --only test,docs
* {{< option name="dev" deprecated=true >}}Include development dependencies.{{< /option >}}
* `--extras (-E)`: Extra sets of dependencies to include.
* `--all-extras`: Include all sets of extra dependencies.
* `--all-groups`: Include all dependency groups when exporting.
* `--without-hashes`: Exclude hashes from the exported file.
* `--with-credentials`: Include credentials for extra indices.
12 changes: 8 additions & 4 deletions src/poetry_plugin_export/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +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("all-groups", None, "Include all dependency groups"),
option(
"extras",
"E",
Expand Down Expand Up @@ -116,11 +116,15 @@ def handle(self) -> int:
f"Extra [{', '.join(sorted(invalid_extras))}] is not specified."
)

if self.option("with") and self.option("all-groups"):
if (
self.option("with") or self.option("without") or self.option("only")
) 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>"
" `<fg=yellow;options=bold>--with</>`, "
"`<fg=yellow;options=bold>--without</>`, "
"or `<fg=yellow;options=bold>--only</>` "
"while exporting using `<fg=yellow;options=bold>--all-groups</>`.</error>"
)
return 1

Expand Down
18 changes: 17 additions & 1 deletion tests/command/test_command_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,23 @@ def test_with_conflicts_all_groups(tester: CommandTester, do_lock: None) -> None

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

tester.execute("--without=bar --all-groups")

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

tester.execute("--only=bar --all-groups")

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

Expand Down

0 comments on commit 6c6f677

Please sign in to comment.