summaryrefslogtreecommitdiff
path: root/examples/unicode_commands.py
diff options
context:
space:
mode:
authorTodd Leonhardt <todd.leonhardt@gmail.com>2019-07-23 22:58:51 -0400
committerTodd Leonhardt <todd.leonhardt@gmail.com>2019-07-23 22:58:51 -0400
commited3a1db1866b19c75f313c667f2481a41e753605 (patch)
tree2f306c64a44f5af84c8bc70d74d7d748937e74b6 /examples/unicode_commands.py
parent5ef4e2018fe854045a366afec5f10682c1438cf2 (diff)
downloadcmd2-git-ed3a1db1866b19c75f313c667f2481a41e753605.tar.gz
Added an example with a unicode command name just to prove to myself that those work ;-)
Diffstat (limited to 'examples/unicode_commands.py')
-rwxr-xr-xexamples/unicode_commands.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/examples/unicode_commands.py b/examples/unicode_commands.py
new file mode 100755
index 00000000..9aa31c69
--- /dev/null
+++ b/examples/unicode_commands.py
@@ -0,0 +1,24 @@
+#!/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 to MyApp. Note the full Unicode support: πŸ˜‡ πŸ’©'
+
+ def do_𝛑print(self, arg):
+ """This command prints 𝛑 to 5 decimal places."""
+ print("𝛑 = {0:.6}".format(math.pi))
+
+
+if __name__ == '__main__':
+ app = UnicodeApp()
+ app.cmdloop()
+