upysh: Add mkdir, newfile commands.

pull/76/head
Paul Sokolovsky 2016-05-30 21:07:49 +03:00
rodzic 74d90076fc
commit a85b23058e
1 zmienionych plików z 14 dodań i 0 usunięć

Wyświetl plik

@ -28,6 +28,8 @@ ls = LS()
def cd(path):
os.chdir(path)
mkdir = os.mkdir
def head(f, n=10):
with open(f) as f:
for i in range(n):
@ -38,6 +40,17 @@ def head(f, n=10):
def cat(f):
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():
print("""
This is 'upysh' help, for builtin Python help run:
@ -46,4 +59,5 @@ builtins.help()
upysh commands:
pwd, cd("new_dir"), ls, ls(...), head(...), cat(...)
mkdir(...), newfile(...)
""")