Run of fresh-releases for aiocmd

Merge these changes:

git pull https://janitor.kali.org/git/aiocmd fresh-releases/main
git pull https://janitor.kali.org/git/aiocmd fresh-releases/pristine-tar
git pull https://janitor.kali.org/git/aiocmd fresh-releases/upstream
Full worker log

Summary

Merged new upstream version: 0.1.5 (was: 0.1.2).

Diff

Branch: main

diff --git a/PKG-INFO b/PKG-INFO
index 501cba0..c635cfb 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: aiocmd
-Version: 0.1.2
+Version: 0.1.5
 Summary: Coroutine-based CLI generator using prompt_toolkit
 Home-page: http://github.com/KimiNewt/aiocmd
 Author: Dor Green
diff --git a/README.md b/README.md
index 1f98e42..83d09fc 100644
--- a/README.md
+++ b/README.md
@@ -23,16 +23,20 @@ class MyCLI(aiocmd.PromptToolkitCmd):
         print("You ran my action!")
         
     def do_add(self, x, y):
-        print(x + y)
-        
-    async def sleep(self, sleep_time=1):
-        await asyncio.sleep(sleep_time)
+        print(int(x) + int(y))
+
+    async def do_sleep(self, sleep_time=1):
+        await asyncio.sleep(int(sleep_time))
         
         
 if __name__ == "__main__":
     asyncio.get_event_loop().run_until_complete(MyCLI().run())
 ``` 
 
+Will create this CLI:
+
+![CLIImage](./docs/image1.png)
+
 ## Extra features
 
 You can implement a custom completion for each command by implementing `_<action>_completions`. 
@@ -46,4 +50,6 @@ class MyCLI(aiocmd.PromptToolkitCmd):
         return WordCompleter([str(i) for i in range(9)])
 ```
 
-You can also set a custom `prompt` and `aliases` parameters for the class (see classdoc).
\ No newline at end of file
+![CLIImage](./docs/image2.png)
+
+You can also set a custom `prompt` and `aliases` parameters for the class (example in docs).
diff --git a/aiocmd.egg-info/PKG-INFO b/aiocmd.egg-info/PKG-INFO
index 501cba0..c635cfb 100644
--- a/aiocmd.egg-info/PKG-INFO
+++ b/aiocmd.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: aiocmd
-Version: 0.1.2
+Version: 0.1.5
 Summary: Coroutine-based CLI generator using prompt_toolkit
 Home-page: http://github.com/KimiNewt/aiocmd
 Author: Dor Green
diff --git a/aiocmd.egg-info/requires.txt b/aiocmd.egg-info/requires.txt
index 1b6df0a..15b0818 100644
--- a/aiocmd.egg-info/requires.txt
+++ b/aiocmd.egg-info/requires.txt
@@ -1 +1,2 @@
 prompt_toolkit>=2.0.9
+packaging
diff --git a/aiocmd/aiocmd.py b/aiocmd/aiocmd.py
index a041702..36bfc74 100644
--- a/aiocmd/aiocmd.py
+++ b/aiocmd/aiocmd.py
@@ -1,7 +1,11 @@
 import asyncio
 import inspect
+import shlex
 import signal
+import sys
 
+import packaging.version
+import prompt_toolkit
 from prompt_toolkit import PromptSession
 from prompt_toolkit.completion import WordCompleter
 from prompt_toolkit.key_binding import KeyBindings
@@ -11,7 +15,10 @@ try:
     from prompt_toolkit.completion.nested import NestedCompleter
 except ImportError:
     from aiocmd.nested_completer import NestedCompleter
-from prompt_toolkit.eventloop.defaults import use_asyncio_event_loop
+
+
+def _is_prompt_toolkit3():
+    return packaging.version.parse(prompt_toolkit.__version__) >= packaging.version.parse("3.0")
 
 
 class ExitPromptException(Exception):
@@ -34,34 +41,40 @@ class PromptToolkitCmd:
     aliases = {"?": "help", "exit": "quit"}
 
     def __init__(self, ignore_sigint=True):
-        use_asyncio_event_loop()
         self.completer = self._make_completer()
         self.session = None
         self._ignore_sigint = ignore_sigint
         self._currently_running_task = None
 
     async def run(self):
-        if self._ignore_sigint:
+        if self._ignore_sigint and sys.platform != "win32":
             asyncio.get_event_loop().add_signal_handler(signal.SIGINT, self._sigint_handler)
         self.session = PromptSession(enable_history_search=True, key_bindings=self._get_bindings())
         try:
             with patch_stdout():
                 await self._run_prompt_forever()
         finally:
-            if self._ignore_sigint:
+            if self._ignore_sigint and sys.platform != "win32":
                 asyncio.get_event_loop().remove_signal_handler(signal.SIGINT)
             self._on_close()
 
     async def _run_prompt_forever(self):
         while True:
             try:
-                result = await self.session.prompt(self.prompt, async_=True, completer=self.completer)
+                if _is_prompt_toolkit3():
+                    result = await self.session.prompt_async(self.prompt, completer=self.completer)
+                else:
+                    # This is done because old versions of prompt toolkit don't support Python 3.5.
+                    # When we deprecate 3.5, this can be removed.
+                    from prompt_toolkit.eventloop import use_asyncio_event_loop
+                    use_asyncio_event_loop()
+                    result = await self.session.prompt(self.prompt, async_=True, completer=self.completer)
             except EOFError:
                 return
 
             if not result:
                 continue
-            args = result.split()
+            args = shlex.split(result)
             if args[0] in self.command_list:
                 try:
                     self._currently_running_task = asyncio.ensure_future(
diff --git a/debian/changelog b/debian/changelog
index e444f7a..41ddba2 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+aiocmd (0.1.5-0kali1) UNRELEASED; urgency=low
+
+  * New upstream release.
+
+ -- Kali Janitor <janitor@kali.org>  Sat, 17 Apr 2021 13:27:18 -0000
+
 aiocmd (0.1.2-0kali1) kali-dev; urgency=medium
 
   * Initial release
diff --git a/setup.py b/setup.py
index 36f8336..3cac3c1 100644
--- a/setup.py
+++ b/setup.py
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
 
 setup(name='aiocmd',
       packages=find_packages("."),
-      version='0.1.2',
+      version='0.1.5',
       author='Dor Green',
       author_email='dorgreen1@gmail.com',
       description='Coroutine-based CLI generator using prompt_toolkit',
@@ -10,7 +10,7 @@ setup(name='aiocmd',
       keywords=['asyncio', 'cmd'],
       license='MIT',
       install_requires=[
-          'prompt_toolkit>=2.0.9'
+          'prompt_toolkit>=2.0.9', 'packaging'
       ],
       classifiers=[
           'License :: OSI Approved :: MIT License',

Branch: pristine-tar

diff --git a/aiocmd_0.1.5.orig.tar.gz.delta b/aiocmd_0.1.5.orig.tar.gz.delta
index 6cca078..0872318 100644
Binary files a/aiocmd_0.1.5.orig.tar.gz.delta and b/aiocmd_0.1.5.orig.tar.gz.delta differ

Branch: upstream

Tag: upstream/0.1.5

Diff is too long (more than 200 lines). Download the raw diff.

Publish History

Resulting package

The resulting binary packages can be installed (if you have the apt repository enabled) by running one of:

apt install -t kali-experimental python3-aiocmd

Lintian Result