Exemple #1
0
 def __init__(self, sock: socket.socket):
     self._sock = sock
     sock_file = sock.makefile('rw')
     Cmdr.__init__(self, stdin=sock_file, stdout=sock_file)
     sys.stdout = sock_file
     Thread.__init__(self, name='HabPrompt', daemon=True)
Exemple #2
0
from datetime import datetime

from cmdr import Cmdr

app = Cmdr("blog_cli")

@app.cmd("blog add")    # Full command
def add_blog():
    """Add a new blog entry"""
    print "adding new blog entry"
    title = raw_input("Title: ")
    text = raw_input("Text: ")
    type = raw_input("Type [N]ote, [B]log")

    print title
    print text
    print type
    print datetime.now()


@app.cmd("blog edit")
def edit_blog(id):
    print "editing blog id %s" % id

app.start()
Exemple #3
0
    def add(self):
        """Adds a new project entry"""
        print "Project Added"

    @subcmd
    def edit(self):
        """Edits a project entry"""
        print "Project Edited"

class LoadTest(Command):
    
    def execute(self):
        print "Execute LoadTest"


app = Cmdr("blog_cli")

b = Blog()
p = Project()


print ""

#pp(b.cmd_dict)

app.register_cmd2(b)
app.register_cmd2(p)

app.start()