-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
102 lines (82 loc) · 2.39 KB
/
main.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
"""
***************************
--------description--------
Autor: Kuro Kitu
Description: FuckOS Shell Main
Date: 2021-08-09 01:31:48
LastEditors: Kuro Kitu
LastEditTime: 2021-08-09 01:40:42
***************************
"""
import os
import json
from os import *
from cmd import Cmd
from pyreadline import Readline
from pathlib import Path
from libs.time import *
from libs.clear import *
from libs.file import *
from libs.fuckflyos import *
version = 1.0
config = None
readline = Readline()
class FuckOSShell(Cmd):
dir = Path.home()
prompt = '\033[0;32;40mFuckOS>\033[0m '
intro = """
\033[0;32m
________ __________ ______ _____
/ ____/ / / / ____/ //_/ __ \/ ___/
/ /_ / / / / / / ,< / / / /\__ \
/ __/ / /_/ / /___/ /| / /_/ /___/ /
/_/ \____/\____/_/ |_\____//____/
Fuck flyos. The code is written like shit.
\"EXIT\".lower ... LMAO
FuckOS Shell V%s
Welcome! Type ? to list commands
Now Time is %s
\033[0m
""" % (version, nowtime())
def do_exit(self, arg):
'exit: exit the application. Shorthand: x q Ctrl-D.'
print("Bye")
return True
def do_time(self, arg):
'time: Get current system time'
print("Time: ", nowtime())
def do_dir(self, arg):
'die: syntax: dir path -- displaya list of files and directories'
if not arg:
print("\n".join(os.listdir(self.dir)))
elif os.path.exists(arg):
print("\n".join(os.listdir(arg)))
else:
print("No such pathexists.")
def do_ls(self, arg):
'ls: syntax: dir path -- displaya list of files and directories'
self.do_dir(arg)
def do_clear(self, arg):
'clear: Clear Screen'
clear()
def do_cd(self, arg):
'Working directory switching'
self.dir = arg
def do_pwd(self, arg):
'Get current path'
print(self.dir)
def do_flyos(self, arg):
'Fuck FlyOS'
runflyos()
def default(self, inp):
if inp == 'x' or inp == 'q':
return self.do_exit(inp)
print("Unknown command: {}\nPlease refer to the help list.".format(inp))
if __name__ == '__main__':
config = json.loads(read_file('./configs/main.json'))
print(type(config))
if(config != None):
clear()
FuckOSShell().cmdloop()