Cmd控制
昨天看到了別的組的部署方案,使用python來控制的,我們是用shell
今天嘗試了一下
code
import os
import sys
from cmd import Cmd
class BingCmd(Cmd):
"""just try try"""
prompt="BingCmd>"
def print_log(self, argv):
print("la la la ")
def do_bing(self, argv):
self.print_log(argv)
def help_bing(self):
print("just print la la la")
if __name__ == "__main__":
# import IPython
# IPython.embed()
BingCmd().cmdloop()
運行結果
$ python3 BingCmd.py
BingCmd>help
Documented commands (type help <topic>):
========================================
bing help
BingCmd>bing
la la la