File: unicode_commands.py

package info (click to toggle)
cmd2 3.2.0%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 2,664 kB
  • sloc: python: 17,488; makefile: 114; sh: 39; javascript: 7
file content (27 lines) | stat: -rwxr-xr-x 764 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/env python
"""A simple example demonstrating support for unicode command names."""

import math

import cmd2


class UnicodeApp(cmd2.Cmd):
    """Example cmd2 application with unicode command names."""

    def __init__(self) -> None:
        super().__init__()
        self.intro = 'Welcome the Unicode example app. Note the full Unicode support:  😇 💩'

    def do_𝛑print(self, _) -> None:  # noqa: PLC2401
        """This command prints 𝛑 to 5 decimal places."""
        self.poutput(f"𝛑 = {math.pi:.6}")

    def do_你好(self, arg) -> None:  # noqa: N802, PLC2401
        """This command says hello in Chinese (Mandarin)."""
        self.poutput("你好 " + arg)


if __name__ == '__main__':
    app = UnicodeApp()
    app.cmdloop()