Skip to content

Commit

Permalink
feat: group options for update strategy and save strategy (#3016)
Browse files Browse the repository at this point in the history
  • Loading branch information
frostming authored Jul 12, 2024
1 parent 817008a commit 6a5bf2c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
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

0 comments on commit 6a5bf2c

Please sign in to comment.