summaryrefslogtreecommitdiff
path: root/examples/unicode_commands.py
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2019-07-24 13:58:42 -0400
committerGitHub <noreply@github.com>2019-07-24 13:58:42 -0400
commitb823665299593fa2f12a5f1a86af11dbb6b7bc4b (patch)
treeb59fc95248a707e0c3ef69874cfccf24c9c5b392 /examples/unicode_commands.py
parent346589e7e81adcd2aff883776249778d57eb4faf (diff)
parent29eeef6829fc7fc4a7e706d90871e8c347de773a (diff)
downloadcmd2-git-b823665299593fa2f12a5f1a86af11dbb6b7bc4b.tar.gz
Merge pull request #739 from python-cmd2/presentation_stuff
Presentation stuff
Diffstat (limited to 'examples/unicode_commands.py')
-rwxr-xr-xexamples/unicode_commands.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/examples/unicode_commands.py b/examples/unicode_commands.py
new file mode 100755
index 00000000..f8381e50
--- /dev/null
+++ b/examples/unicode_commands.py
@@ -0,0 +1,27 @@
+#!/usr/bin/env python
+# coding=utf-8
+"""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):
+ super().__init__()
+ self.intro = 'Welcome the Unicode example app. Note the full Unicode support: 😇 💩'
+
+ def do_𝛑print(self, _):
+ """This command prints 𝛑 to 5 decimal places."""
+ self.poutput("𝛑 = {0:.6}".format(math.pi))
+
+ def do_你好(self, arg):
+ """This command says hello in Chinese (Mandarin)."""
+ self.poutput("你好 " + arg)
+
+
+if __name__ == '__main__':
+ app = UnicodeApp()
+ app.cmdloop()