8000 upip: Add quick help. · micropython/micropython-lib@16431da · GitHub
[go: up one dir, main page]

Skip to content

Commit 16431da

Browse files
author
Paul Sokolovsky
committed
upip: Add quick help.
1 parent b4dbd50 commit 16431da

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

upip/upip.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,22 +116,35 @@ def install_pkg(pkg_spec, install_path):
116116
f = tarfile.TarFile("pkg.tar")
117117
return install_tar(f, install_path)
118118

119+
def help():
120+
print("upip - Simple PyPI package manager for MicroPython")
121+
print("Usage: micropython -m upip install <package>... | -r <requirements.txt>")
122+
print("""\
123+
Note: only micropython-* packages are supported for installation, upip does not
124+
support arbitrary code in setup.py.""")
125+
sys.exit(1)
126+
119127
def main():
120128
install_path = None
121129

130+
if len(sys.argv) < 2 or sys.argv[1] == "-h" or sys.argv[1] == "--help":
131+
help()
132+
122133
if sys.argv[1] != "install":
123134
fatal("Only 'install' command supported")
124135

125136
to_install = []
126137

127138
i = 2
128139
while i < len(sys.argv) and sys.argv[i][0] == "-":
129-
opt = sys.argv[i][1]
140+
opt = sys.argv[i]
130141
i += 1
131-
if opt == "p":
142+
if opt == "-h" or opt == "--help":
143+
help()
144+
elif opt == "-p":
132145
install_path = sys.argv[i]
133146
i += 1
134-
elif opt == "r":
147+
elif opt == "-r":
135148
list_file = sys.argv[i]
136149
i += 1
137150
with open(list_file) as f:
@@ -156,6 +169,9 @@ def main():
156169
print("Installing to: " + install_path)
157170

158171
to_install.extend(sys.argv[i:])
172+
if not to_install:
173+
help()
174+
159175
# sets would be perfect here, but don't depend on them
160176
installed = []
161177
while to_install:

0 commit comments

Comments
 (0)
0