Exemplo n.º 1
0
def hRun(c, inp):
    if (len(inp) == 2):
        temp = len(cmdHistory) - inp[1]
    else:
        temp = len(cmdHistory) - 2

    main.scw(">> " + cmdHistory[temp])
    i = input("? ")

    if (i.lower() == ""):
        main(cmdHistory[temp])

    elif (i.lower() != "n"):
        error(2, inp[0])
Exemplo n.º 2
0
def load():
    # Slowly appending commands :)
    newCommA(True, "turn", turnValidate, turnRun, turnUsage, turnDesc)

    a = main.attribute(True)
    a2 = main.attribute(True)
    c = main.command("ch", [a, a2])
    c.validate = main.MethodType(chValidate, c)
    c.usage = main.MethodType(chUsage, c)
    c.run = main.MethodType(chRun, c)
    c.description = main.MethodType(chDesc, c)
    main.commands.append(c)

    main.scw("commands loaded")
    main.scw(main.commands[0])
Exemplo n.º 3
0
def helpDesc(c):
    main.scw(
        "I`m assuming you know what help does, since you just used it. Well it shows you all of the commands you can enter here :)"
    )
    main.scw(
        "If you type 'help' <command> it will show you the commands description."
    )
    main.scw(
        "If you just type 'help' it will show all of the commands with their usage."
    )
Exemplo n.º 4
0
def turnDesc(c):
    main.scw(
        "This command makes you turn around. Could be useful for a text-based RPG maybe?"
    )
Exemplo n.º 5
0
def chUsage(c):
    main.scw("ch + 'Name of a first file' 'Name of a second file'")
Exemplo n.º 6
0
def turnUsage(c):
    main.scw("turn + 'left' / 'right' / 'backward' / 'forward' / ")
    main.scw("       'North' / 'South' / 'East' / 'West'")
Exemplo n.º 7
0
def chRun(c, inp):
    main.scw("You changed the name of " + inp[1] + " to " + inp[2] + ".")
Exemplo n.º 8
0
def turnRun(c, inp):
    main.scw("You turned towards the", inp[1] + ".")
Exemplo n.º 9
0
def helpRun(c, inp):
    main.scw("yee")
    main.scw("Type 'help' <command> for commands description.")
    main.scw()
    if (len(inp) > 1):
        count = 0
        for i in commands:
            if (inp[1] == i.label):
                i.description()
                break
    else:
        for i in range(0, len(commands)):
            main.scw(str(i + 1) + ". " + commands[i].label, end="")

            if (len(commands[i].att) >= 1):
                main.scw(" -  ", end="")
                commands[i].usage()
            else:
                main.scw()
Exemplo n.º 10
0
def exitDesc(c):
    main.scw(
        "By typing 'exit', the shells main loop will end and the python script will terminate."
    )
Exemplo n.º 11
0
def restartDesc(c):
    main.scw(
        "This command restarts this 'shell'. That means it clears the command-history and reloads all of the commands as well as the config file."
    )
Exemplo n.º 12
0
def hUsage(c):
    main.scw("h (<1-max number>)")
Exemplo n.º 13
0
def helpUsage(c):
    main.scw("help (<command>)")
Exemplo n.º 14
0
def chDesc(c):
    main.scw(
        "'Ch' changes the name of a imaginary file. I doesn`t really do anything to be honest. It might at sometime though."
    )
Exemplo n.º 15
0
def hDesc(c):
    main.scw(
        "This command lets you use a command you have recently typed already. It gives you acces to the command history."
    )
    main.scw(
        "You can also type 'h' <number from 1-number of entered commands or maximum length>. This number increases he further back in he history you get."
    )
    main.scw(
        "For the latest command you would type 'h' or 'h 1'. For the secodn latest 'h 2' and so on..."
    )
    main.scw(
        "You will get a question mark. You either type enter to execute the command like shown above or type 'n' to abort the process."
    )
    main.scw()
    main.scw("You can set the historys maxium length in the config.py file.")
Exemplo n.º 16
0
def restartRun(c, inp):
    main.scw()
    main.scw("Restarting shell")
    main.scw()
    main.scw("-------------------------------------------------------")
    return "restart"
Exemplo n.º 17
0
def exitRun(c, inp):
    main.scw("Goodbye")
    main.scw()
    sys.exit()