| 1 |
|
| 2 |
"""A simple example demonstrating support for unicode command names.""" |
| 3 |
|
| 4 |
import math |
| 5 |
|
| 6 |
import cmd2 |
| 7 |
|
| 8 |
|
| 9 |
class UnicodeApp(cmd2.Cmd): |
| 10 |
"""Example cmd2 application with unicode command names.""" |
| 11 |
|
| 12 |
def __init__(self) -> None: |
| 13 |
super().__init__() |
| 14 |
self.intro = "Welcome the Unicode example app. Note the full Unicode support: π π©" |
| 15 |
|
| 16 |
def do_πprint(self, _) -> None:01 |
| 17 |
"""This command prints π to 5 decimal places.""" |
| 18 |
self.poutput(f"π = {math.pi:.6}") |
| 19 |
|
| 20 |
def do_δ½ ε₯½(self, arg) -> Non2401 |
| 21 |
"""This command says hello in Chinese (Mandarin).""" |
| 22 |
self.poutput("δ½ ε₯½ " + arg) |
| 23 |
|
| 24 |
|
| 25 |
if __name__ == "__main__": |
| 26 |
app = UnicodeApp() |
| 27 |
app.cmdloop() |