【发布时间】:2018-07-12 07:29:07
【问题描述】:
我正在尝试在我的 python 代码中的帮助部分添加一个选项。当用户使用 -h 运行 cmd 调用时,他们将收到以下提示。
如果他们不知道什么节目可用,我想选择 -sl 选项,它将运行 cmd 并将列表作为结果输出到同一终端。由于我缺乏经验和涉及 awk 的 cmd,引用也被证明是一个问题。
未触及的命令行调用如下: 工作信息--allshow | awk -F "[, ]+" '/jobs/{print $(NF-1)}'
showlist = "jobsinfo --allshow | awk -F " + "[, ]+" + "'/jobs/{print $(NF-1)}'"
# Help section
parser = argparse.ArgumentParser(description="Check the render queue for a time period")
parser.add_argument("-l", "--location", default=site, help="The location you want to check. ""#Examples: london, denver, montreal...")
parser.add_argument("-p", "--project", default="New", help="The project you want to check. The Default is set to new. "
"#Examples: Please see SHOW list here: http://dnet.dneg.com/display/COMMS/SHOW+INFORMATION")
# parser.add_argument("-sl", "--showlist", action=showlist, help="List the Shows currently on Servers.")
parser.add_argument("-d", "--days", type=int, default=14, help="The number of days you wish to go back. The default is set to 14 days. "
"#Examples: -d 3, -d 9, -d 14")
args = parser.parse_args()
任何帮助将不胜感激。
谢谢!
【问题讨论】: