cli-ih 0.5.1__py3-none-any.whl → 0.5.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
InputHandler/__init__.py CHANGED
@@ -28,10 +28,11 @@ def setup_logging():
28
28
 
29
29
  class InputHandler:
30
30
  #logging.basicConfig(level=logging.INFO, format='[%(asctime)s | %(levelname)s]: %(message)s', datefmt='%B %d %H:%M:%S')
31
- def __init__(self, thread_mode = True):
31
+ def __init__(self, thread_mode = True, cursor = ""):
32
32
  self.commands = {}
33
33
  self.is_running = False
34
34
  self.thread_mode = thread_mode
35
+ self.cursor = f"{cursor.strip()} "
35
36
  self.thread = None
36
37
  self.register_default_commands()
37
38
 
@@ -70,7 +71,7 @@ class InputHandler:
70
71
  """Continuously listens for user input and processes commands."""
71
72
  while self.is_running:
72
73
  try:
73
- user_input = input().strip()
74
+ user_input = input(self.cursor).strip()
74
75
  if not user_input:
75
76
  continue
76
77
 
@@ -0,0 +1,49 @@
1
+ Metadata-Version: 2.1
2
+ Name: cli_ih
3
+ Version: 0.5.2
4
+ Summary: A background command handler for python's command line interface.
5
+ Author-email: Hotment <michatchuplay@gmail.com>
6
+ Requires-Python: >=3.8
7
+ Description-Content-Type: text/markdown
8
+
9
+ # InputHandler Library
10
+
11
+ A lightweight Python library for creating interactive command-line interfaces with custom command registration and input handling. It supports threaded input processing and includes enhanced logging with color-coded output.
12
+
13
+ ## Features
14
+
15
+ - Command registration system with descriptions
16
+ - Threaded or non-threaded input handling
17
+ - Colored logging with support for debug mode
18
+ - Built-in `help`, `debug`, and `exit` commands
19
+ - Error handling for missing or invalid command arguments
20
+
21
+ ## Installation
22
+
23
+ pip install cli-ih
24
+
25
+ ## Quick Start
26
+
27
+ ```python
28
+ from cli-ih import InputHandler
29
+
30
+ def greet(args):
31
+ print(f"Hello, {' '.join(args)}!")
32
+
33
+ handler = InputHandler()
34
+ handler.register_command("greet", greet, "Greets the user. Usage: greet [name]")
35
+ handler.start()
36
+
37
+ # Now type commands like:
38
+ # > greet world
39
+ # > help
40
+ # > debug
41
+ # > exit
42
+ ```
43
+
44
+ ## Additional Info
45
+
46
+ - You can also import the `logging` module from `cli-ih` to use the same config as the module
47
+ - You can provide the `thread_mode` param to the `InputHandler` class to set if it shoud run in a thread or no.
48
+ (If you are using the `cli-ih` module on its own without any other background task set `thread_mode=False` to false)
49
+ - You can also provide a `cursor` param to the `InputHandler` class to set the cli cursor (default cusor is empty)
@@ -0,0 +1,5 @@
1
+ InputHandler/__init__.py,sha256=_OUI_BT6EN1wfWmLtm94bFLlHLvK01TKCzifEg2uNYQ,4932
2
+ cli_ih-0.5.2.dist-info/METADATA,sha256=rupWmHvik9X9k0ZhHXOiuL_ZtGqCpkqiqjxgMm6NRwQ,1600
3
+ cli_ih-0.5.2.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
4
+ cli_ih-0.5.2.dist-info/top_level.txt,sha256=1wOYpDwNGBjhQWhD3dRvyWH1Hh4U6HWbAqJAq-p4Izg,13
5
+ cli_ih-0.5.2.dist-info/RECORD,,
@@ -1,7 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: cli_ih
3
- Version: 0.5.1
4
- Summary: A background command handler for python's command line interface.
5
- Author-email: Hotment <michatchuplay@gmail.com>
6
- Requires-Python: >=3.8
7
- Requires-Dist: logging==0.4.9.6
@@ -1,5 +0,0 @@
1
- InputHandler/__init__.py,sha256=w4qMQJe00-d-PiXCRQ26fudlbiDzfAl3AsK4UY713R8,4864
2
- cli_ih-0.5.1.dist-info/METADATA,sha256=iZbebVtc4-up01w3UfkEmzj3MtiFinJPvWv-tWcmBnY,235
3
- cli_ih-0.5.1.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
4
- cli_ih-0.5.1.dist-info/top_level.txt,sha256=1wOYpDwNGBjhQWhD3dRvyWH1Hh4U6HWbAqJAq-p4Izg,13
5
- cli_ih-0.5.1.dist-info/RECORD,,
File without changes