kopia lustrzana https://github.com/micropython/micropython-lib
upysh: Add mkdir, newfile commands.
rodzic
74d90076fc
commit
a85b23058e
|
@ -28,6 +28,8 @@ ls = LS()
|
||||||
def cd(path):
|
def cd(path):
|
||||||
os.chdir(path)
|
os.chdir(path)
|
||||||
|
|
||||||
|
mkdir = os.mkdir
|
||||||
|
|
||||||
def head(f, n=10):
|
def head(f, n=10):
|
||||||
with open(f) as f:
|
with open(f) as f:
|
||||||
for i in range(n):
|
for i in range(n):
|
||||||
|
@ -38,6 +40,17 @@ def head(f, n=10):
|
||||||
def cat(f):
|
def cat(f):
|
||||||
head(f, 1 << 30)
|
head(f, 1 << 30)
|
||||||
|
|
||||||
|
def newfile(path):
|
||||||
|
print("Type file contents line by line, finish with EOF (Ctrl+D).")
|
||||||
|
with open(path, "w") as f:
|
||||||
|
while 1:
|
||||||
|
try:
|
||||||
|
l = input()
|
||||||
|
except EOFError:
|
||||||
|
break
|
||||||
|
f.write(l)
|
||||||
|
f.write("\n")
|
||||||
|
|
||||||
def help():
|
def help():
|
||||||
print("""
|
print("""
|
||||||
This is 'upysh' help, for builtin Python help run:
|
This is 'upysh' help, for builtin Python help run:
|
||||||
|
@ -46,4 +59,5 @@ builtins.help()
|
||||||
|
|
||||||
upysh commands:
|
upysh commands:
|
||||||
pwd, cd("new_dir"), ls, ls(...), head(...), cat(...)
|
pwd, cd("new_dir"), ls, ls(...), head(...), cat(...)
|
||||||
|
mkdir(...), newfile(...)
|
||||||
""")
|
""")
|
||||||
|
|
Ładowanie…
Reference in New Issue