Browse Source

added a fake cd command and cosmetics

master
Johannes Findeisen 4 years ago
parent
commit
03da6a3279
2 changed files with 25 additions and 12 deletions
  1. +4
    -1
      README.md
  2. +21
    -11
      hsh

+ 4
- 1
README.md View File

@@ -1,4 +1,7 @@
This is the hsh project. It is the Hanez' Shell... ;)
This is the hsh project.
========================

It is the Hanez' Shell... ;)

It is just a fun project for playing aroung with Python. It aims to become a
hacking game, a fake terminal or something like that.

+ 21
- 11
hsh View File

@@ -34,7 +34,7 @@ def star():
00_$$$$$$$$$$$$$$$$$$$$$$$$$_00 Please enter \"help\" for a list of
00_$$$$$$$$$$$$$$$$$$$$$_00 available commands.
00_$$$$$$$$$$$$$$$$$_00
00_$$$$$$$$$$$$$_00 Please use the \"login\" command to.
00_$$$$$$$$$$$$$_00 Please use the \"login\" command to
00_$$$$$$$$$$$$$$$_00 authenticate.
00_$$$$$_0000_$$$$$$_00
00_$$$$_00 00_$$$$$_00 Thanks!
@@ -52,17 +52,20 @@ def signal_handler(signal, frame):
#sys.exit(0)


class MyPrompt(Cmd):
class HshPrompt(Cmd):

authenticated = False
password = "1234"
status = "Normal"
username = "Not logged in!"

path = ""

def emptyline(self):
return

def do_hello(self, args):
@staticmethod
def do_hello(args):
"""Says hello. If you provide a name, it will greet you with it."""
if len(args) == 0:
name = 'stranger'
@@ -70,15 +73,14 @@ class MyPrompt(Cmd):
name = args
print('Hello, %s' % name)

def do_quit(self, args):
@staticmethod
def do_quit(args):
"""Disconnects from server."""
print('Disconnecting...')
raise SystemExit

#def do_help(self, args):
# print('HELP!!!')

def do_welcome(self, args):
@staticmethod
def do_welcome(args):
"""Shows welcome message"""
print(star())

@@ -103,18 +105,26 @@ class MyPrompt(Cmd):
self.username = "Not logged in!"

def do_status(self, args):
"""Shows your current user status"""
print('Username: ' + self.username)
print('Authentication status: ' + self.status)
print('Current path: ' + self.path)

def do_restricted(self, args):
if not self.authenticated:
print(RED+'Restricted access!'+END)

def do_cd(self, args):
if len(args) != 0:
self.path = args
prompt.prompt = PURPLE+self.path+BLUE+' > '+END
else:
print(RED+'Not found!'+END)



if __name__ == '__main__':
signal.signal(signal.SIGINT, signal_handler)
#print('Press Ctrl+C')
#signal.pause()
prompt = MyPrompt()
prompt = HshPrompt()
prompt.prompt = BLUE+'> '+END
prompt.cmdloop(star())

Loading…
Cancel
Save