Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: group options for update strategy and save strategy #3016

Merged
merged 2 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions news/3016.feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Group options for update strategy and save strategy.
28 changes: 14 additions & 14 deletions src/pdm/cli/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,35 +288,37 @@ def no_isolation_option(
)
groups_group.options.append(dev_group)

save_strategy_group = ArgumentGroup("save_strategy", is_mutually_exclusive=True)
save_strategy_group.add_argument(
save_strategy_group = ArgumentGroup("Save Strategy")
_save_sub_group = ArgumentGroup("save_strategy", is_mutually_exclusive=True)
_save_sub_group.add_argument(
"--save-compatible",
action="store_const",
dest="save_strategy",
const="compatible",
help="Save compatible version specifiers",
)
save_strategy_group.add_argument(
_save_sub_group.add_argument(
"--save-wildcard",
action="store_const",
dest="save_strategy",
const="wildcard",
help="Save wildcard version specifiers",
)
save_strategy_group.add_argument(
_save_sub_group.add_argument(
"--save-exact",
action="store_const",
dest="save_strategy",
const="exact",
help="Save exact version specifiers",
)
save_strategy_group.add_argument(
_save_sub_group.add_argument(
"--save-minimum",
action="store_const",
dest="save_strategy",
const="minimum",
help="Save minimum version specifiers",
)
save_strategy_group.add_argument(_save_sub_group)

skip_option = Option(
"-k",
Expand All @@ -330,35 +332,37 @@ def no_isolation_option(
default=from_splitted_env("PDM_SKIP_HOOKS", ","),
)

update_strategy_group = ArgumentGroup("update_strategy", is_mutually_exclusive=True)
update_strategy_group.add_argument(
update_strategy_group = ArgumentGroup("Update Strategy")
_update_sub_group = ArgumentGroup("update_strategy", is_mutually_exclusive=True)
_update_sub_group.add_argument(
"--update-reuse",
action="store_const",
dest="update_strategy",
const="reuse",
help="Reuse pinned versions already present in lock file if possible",
)
update_strategy_group.add_argument(
_update_sub_group.add_argument(
"--update-eager",
action="store_const",
dest="update_strategy",
const="eager",
help="Try to update the packages and their dependencies recursively",
)
update_strategy_group.add_argument(
_update_sub_group.add_argument(
"--update-all",
action="store_const",
dest="update_strategy",
const="all",
help="Update all dependencies and sub-dependencies",
)
update_strategy_group.add_argument(
_update_sub_group.add_argument(
"--update-reuse-installed",
action="store_const",
dest="update_strategy",
const="reuse-installed",
help="Reuse installed packages if possible",
)
update_strategy_group.add_argument(_update_sub_group)

project_option = Option(
"-p",
Expand All @@ -382,10 +386,6 @@ def no_isolation_option(
clean_group.add_argument("--clean", action="store_true", help="Clean packages not in the lockfile")
clean_group.add_argument("--only-keep", action="store_true", help="Only keep the selected packages")

sync_group = ArgumentGroup("sync", is_mutually_exclusive=True)
sync_group.add_argument("--sync", action="store_true", dest="sync", help="Sync packages")
sync_group.add_argument("--no-sync", action="store_false", dest="sync", help="Don't sync packages")

packages_group = ArgumentGroup("Package Arguments")
packages_group.add_argument(
"-e",
Expand Down
Loading