Asyncio implementation of Cmd Python lib.
Project description
asynccmd Async implementation of cmd Python lib.
It’s very simple like original Cmd lib https://docs.python.org/3.6/library/cmd.html.
The mechanic is very similar. You have Cmd class, you can override class method and add yours own.
import asyncio
import sys
from asynccmd import Cmd
class SimpleCommander(Cmd):
def __init__(self, mode, intro, prompt):
super().__init__(mode=mode)
self.intro = intro
self.prompt = prompt
self.loop = None
def do_tasks(self, arg):
"""
Fake command. Type "tasks {arg}"
:param arg: args occurred from cmd after command
:return:
"""
print(asyncio.Task.all_tasks(loop=self.loop))
def start(self, loop=None):
self.loop = loop
super().cmdloop(loop)
print(super().mode)
if sys.platform == 'win32':
loop = asyncio.ProactorEventLoop()
mode = "Run"
else:
loop = asyncio.get_event_loop()
mode = "Reader"
cmd = SimpleCommander(mode=mode, intro="This is example", prompt="example> ")
cmd.start(loop)
try:
loop.run_forever()
except KeyboardInterrupt:
loop.stop()
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file asynccmd-0.2.1.tar.gz.
File metadata
- Download URL: asynccmd-0.2.1.tar.gz
- Upload date:
- Size: 4.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
770f3b44734ee7404d06fa0e22ec2a47071b5e1cbc5aefc7c68866c222fd3760
|
|
| MD5 |
9c670490e147b570d52368e1272fc7ca
|
|
| BLAKE2b-256 |
58c6a4da38aec47ae34546093b5e3e92aada2407bc96674f1df3ef4b4719a1da
|
File details
Details for the file asynccmd-0.2.1-py3.7.egg.
File metadata
- Download URL: asynccmd-0.2.1-py3.7.egg
- Upload date:
- Size: 7.4 kB
- Tags: Egg
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
941a6d699b2e0f66ff062a95d587a8986399b789bb78a376b85ce29557d13a7f
|
|
| MD5 |
c3de8b5ac9392efe264afd853a1978d2
|
|
| BLAKE2b-256 |
d06a663cf53880a2db56fe374debc2431f076e40fd77005b785f03c076d4d1c2
|
File details
Details for the file asynccmd-0.2.1-py3.6.egg.
File metadata
- Download URL: asynccmd-0.2.1-py3.6.egg
- Upload date:
- Size: 7.4 kB
- Tags: Egg
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
44f3f898d49f5f89293a60a428128a8410c2a31421dd8069635df22b2774fe1f
|
|
| MD5 |
f7a3e5e6e60c1ccb00adcaa3854ab641
|
|
| BLAKE2b-256 |
a5ed8e8fe1980db920b879d2be7d40ae6e37d88e7bcbdecc72c699ab0e75a030
|
File details
Details for the file asynccmd-0.2.1-py3.5.egg.
File metadata
- Download URL: asynccmd-0.2.1-py3.5.egg
- Upload date:
- Size: 7.5 kB
- Tags: Egg
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8d3b731396449852b82c4847e6d9074b84e3a2e9ba80d866ecde069cfbb7c426
|
|
| MD5 |
25f11459b03433eb0437f769befdf0e0
|
|
| BLAKE2b-256 |
8d2bd10d15bbefaf899379587076e9e0c12cca6b09584aa8bf3948da142214f2
|