Skip to content

Commit 464f8d9

Browse files
committed
Improved README.
1 parent e663a98 commit 464f8d9

File tree

4 files changed

+73
-7
lines changed

4 files changed

+73
-7
lines changed

README.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,68 @@
1919

2020
A set of helpers to implement a text user interface (TUI) in a terminal.
2121

22+
## Features
23+
* Colored command line outputs based on colorama
24+
* Message classification in fatal, error, warning, normal, quiet, ...
25+
* Get information like terminal dimensions from underlying terminal window
26+
27+
28+
## Simple Terminal Application
29+
30+
This is a minimal terminal application example which inherits from `LineTerminal`.
31+
32+
```python
33+
from pyTerminalUI import LineTerminal
34+
35+
class Application(LineTerminal):
36+
def __init__(self):
37+
super().__init__(verbose=True, debug=True, quiet=False)
38+
39+
def run(self):
40+
self.WriteNormal("This is a simple application.")
41+
self.WriteWarning("This is a warning message.")
42+
self.WriteError("This is an error message.")
43+
44+
# entry point
45+
if __name__ == "__main__":
46+
Application.versionCheck((3,6,0))
47+
app = Application()
48+
app.run()
49+
app.exit()
50+
```
51+
52+
## Complex Terminal Application
53+
54+
This example hands over the terminal instance to a submodule, which implements
55+
`ILineTerminal`, so the submodule can also use the terminal's writing methods.
56+
57+
```python
58+
from pathlib import Path
59+
from pyTerminalUI import LineTerminal, ILineTerminal
60+
61+
class SubModule(ILineTerminal):
62+
def __init__(self, configFile, terminal):
63+
super().__init__(terminal)
64+
65+
if not configFile.exists():
66+
self.WriteError("Config file '{0!s}' not found.".format(configFile))
67+
68+
69+
class Application(LineTerminal):
70+
def __init__(self):
71+
super().__init__(verbose=True, debug=True, quiet=False)
72+
73+
mod = SubModule(Path("config.yml"), self)
74+
75+
def run(self):
76+
pass
77+
78+
# entry point
79+
if __name__ == "__main__":
80+
app = Application()
81+
app.run()
82+
```
83+
2284

2385
## Contributors
2486

pyTerminalUI/__init__.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -564,23 +564,27 @@ def BaseIndent(self, value):
564564
self._baseIndent = value
565565

566566
_LOG_MESSAGE_FORMAT__ = {
567-
Severity.Fatal: "{DARK_RED}{message}{NOCOLOR}",
568-
Severity.Error: "{RED}{message}{NOCOLOR}",
567+
Severity.Fatal: "{DARK_RED}[FATAL] {message}{NOCOLOR}",
568+
Severity.Error: "{RED}[ERROR] {message}{NOCOLOR}",
569569
Severity.Quiet: "{WHITE}{message}{NOCOLOR}",
570-
Severity.Warning: "{YELLOW}{message}{NOCOLOR}",
570+
Severity.Warning: "{YELLOW}[WARNING]{message}{NOCOLOR}",
571571
Severity.Info: "{WHITE}{message}{NOCOLOR}",
572-
Severity.DryRun: "{DARK_CYAN}{message}{NOCOLOR}",
572+
Severity.DryRun: "{DARK_CYAN}[DRY] {message}{NOCOLOR}",
573573
Severity.Normal: "{WHITE}{message}{NOCOLOR}",
574574
Severity.Verbose: "{GRAY}{message}{NOCOLOR}",
575575
Severity.Debug: "{DARK_GRAY}{message}{NOCOLOR}"
576576
} #: Message formatting rules.
577577

578578
def ExitOnPreviousErrors(self):
579+
"""Exit application if errors have been printed."""
580+
579581
if self._errorCounter > 0:
580582
self.WriteFatal("Too many errors in previous steps.")
581583
self.fatalExit()
582584

583585
def ExitOnPreviousWarnings(self):
586+
"""Exit application if warnings have been printed."""
587+
584588
if self._warningCounter > 0:
585589
self.WriteError("Too many warnings in previous steps.")
586590
self.exit()

requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
pyExceptions>=0.1.11
2-
pyMetaClasses>=1.0.0
1+
pyExceptions>=1.0.0
2+
pyMetaClasses>=1.1.0

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050

5151
setuptools.setup(
5252
name=projectName,
53-
version="1.3.2",
53+
version="1.3.3",
5454

5555
author="Patrick Lehmann",
5656
author_email="Paebbels@gmail.com",

0 commit comments

Comments
 (0)