Skip to content

Commit e2e6ab3

Browse files
committed
feat: allow update given package manager
Signed-off-by: Frost Ming <me@frostming.com>
1 parent 96dab6a commit e2e6ab3

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/onepm/cli.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,15 @@ def parse_args() -> argparse.Namespace:
1313
"use", help="Use the package manager given by the requirement spec"
1414
)
1515
use_cmd.add_argument("spec", help="package manager requirement spec")
16-
commands.add_parser(
16+
update_cmd = commands.add_parser(
1717
"update", aliases=["up"], help="Update the package manager used in the project"
1818
)
19+
update_cmd.add_argument(
20+
"name",
21+
help="The name of package manager",
22+
choices=PACKAGE_MANAGERS,
23+
nargs=argparse.OPTIONAL,
24+
)
1925
cleanup_cmd = commands.add_parser(
2026
"cleanup", help="Clean up installations of specified package manager or all"
2127
)
@@ -50,7 +56,7 @@ def main():
5056
case "install":
5157
core.get_package_manager()
5258
case "update" | "up ":
53-
core.update_package_manager()
59+
core.update_package_manager(args.name)
5460
case "use":
5561
core.use_package_manager(args.spec)
5662
case "cleanup":

src/onepm/core.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,8 @@ def _pip_location(self) -> Path:
211211
os.replace(wheel, shared_pip)
212212
return shared_pip / "pip"
213213

214-
def update_package_manager(self) -> None:
215-
pm, requirement = self.detect_package_manager()
214+
def update_package_manager(self, name: str | None = None) -> None:
215+
pm, requirement = self.detect_package_manager(name)
216216
self.install_tool(pm.name, requirement)
217217

218218
def use_package_manager(self, spec: str) -> None:

0 commit comments

Comments
 (0)