-
Notifications
You must be signed in to change notification settings - Fork 6
/
pip.py
72 lines (68 loc) · 2.87 KB
/
pip.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
from pathlib import Path
from typing import Tuple
from nepattern import URL
from arclet.alconna import Alconna, Args, Option, Subcommand, count, store_true
pip = Alconna(
"/pip",
Subcommand(
"install",
Args.requirements(str, multiple="*"),
Option("-r|--requirement", Args.rfile(Path)),
Option("-c|--constraint", Args.cfile(Path)),
Option("--no-deps", default=False, action=store_true),
Option("--pre", default=False, action=store_true),
Option("-e|--editable", Args.path_or_url([URL, Path])),
Option("--dry-run"),
Option("-t|--target", Args.dir(Path)),
Option("--platform", Args.plat(str)),
Option("--python-version", Args.python_version(str)),
Option("--implementation", Args.impl(["pp", "jy", "cp", "ip", "py"])),
Option("--abi", Args.abi(str)),
Option("-U|--upgrade", default=False, action=store_true),
Option("--force-reinstall", default=False, action=store_true),
Option("-i|--index-url", Args.url(URL))
# and more ....
),
Subcommand("download"),
Subcommand("uninstall"),
Subcommand("freeze"),
Subcommand("inspect"),
Subcommand("list"),
Subcommand("show"),
Subcommand("check"),
Subcommand("config"),
Subcommand("search"),
Subcommand("cache"),
Subcommand("wheel"),
Subcommand("hash"),
Subcommand("completion"),
Subcommand("debug"),
Subcommand("help"),
Option("--debug", default=False, action=store_true),
Option("--isolated", default=False, action=store_true),
Option("--require-virtualenv", default=False, action=store_true),
Option("--python", Args.python(str)),
Option("-v|--verbose", action=count, default=0),
Option("-V|--version"),
Option("-q|--quiet", default=False, action=store_true),
Option("--log", Args.log_path(Path)),
Option("--no-input", default=False, action=store_true),
Option("--proxy", Args.proxy(str)),
Option("--retries", Args.count(int)),
Option("--timeout", Args.sec(float)),
Option("--exists-action", Args.action(["s", "i", "w", "b", "a"])),
Option("--trusted-host", Args.hostname(str)),
Option("--cert", Args.cert_path(Path)),
Option("--client-cert", Args.client_path(Path)),
Option("--cache-dir", Args.dir(Path)),
Option("--no-cache-dir", default=False, action=store_true),
Option("--disable-pip-version-check", default=False, action=store_true),
Option("no-color", default=False, action=store_true),
Option("no-python-version-warning", default=False, action=store_true),
Option("--use-feature", Args.feature(str, multiple=True)),
Option("--use-deprecated", Args.feature(str, multiple=True)),
)
res = pip.parse("/pip install arclet-alconna -U -vvv")
print(res.query[bool]("install.upgrade.value"))
print(res.query[Tuple[str, ...]]("install.args.requirements"))
print(res.query[int]("verbose.value"))