具有多个命令的命令行应用程序的框架。
MultiApp的Python项目详细描述
多应用程序是一个框架,因此您可以让您的应用程序快速而简单 在命令行中有多个函数的方法。使用起来很简单-你 只需创建一个multiapp的子类,如下所示:
class FileStamper(MultiApp): ''' FileStamper will manipulate logfiles in a special format. It is blah blah blah...(more long description) ''' name = "FileStamper" version = "1.0" shortdesc = "A logging package." def do_log(self, file, message): # User types log at the prompt # Add the message to the log... do_log.usage = "FILENAME MESSAGE" do_log.descr = "Adds a new entry to the log file." def do_latest_entry(self, file, number=5): # User types latest-entry # Retrieve the latest log message... do_latest_entry.usage = "FILENAME [NUMBER]" do_latest_entry.descr = "Retrieves the log's latest entry."
多应用程序为您的程序提供:
- 参数解析,您可以将其视为普通方法参数
- 现成的集成帮助系统
- 定义功能的非常不显眼的方法