Creating a CLI (Shell?) in Python

自古美人都是妖i 提交于 2019-12-04 07:33:36

Or if you want a cmd shell, you could use the cmd lib. It offers python interfaces to making command lines. http://docs.python.org/library/cmd.html

I think you should now to use simple argparse module to get command line arguments


import argparse

from functions import delete

parser = argparse.ArgumentParser()
parser.add_argument('-f', '--file')

args = parser.parse_args()

delete(args.file)

Hope this should work for you

Sultan

You might want to check my personal REPL for some inspiration. I wrote it during a tutorial series. Actual source may be found here. It probably does a few things you won't need... Still it could be a good read. :)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!