runp将python函数从文件导出到命令行

runp的Python项目详细描述


https://travis-ci.org/vascop/runp.svghttps://coveralls.io/repos/vascop/runp/badge.svg?branch=master&service=github

runp将python函数从文件导出到命令行。 您不需要更改现有代码。

如果您有一个名为myfile.py的文件,文件名为:

def foo():
    """beeps a lot"""
    print "beep beep"

def bar(text):
    """Prints things

    Args:
        text (str): The text to print
    """
    print text

您想在命令行中运行它,只需执行以下操作:

$ runp myfile.py foo
beep beep

您还可以向函数传递参数:

$ runp myfile.py bar:"this is sweet!"
this is sweet!

名称以\开头的函数被隐藏。

您可以使用以下命令列出可用的功能:

$ runp myfile.py -l
Available functions:
foo    beeps a lot
bar    Prints things

获取有关特定功能的信息:

$ runp myfile.py -d bar
Displaying docstring for function bar in module myfile

bar(text)
    Prints things

    Args:
        text (str): The text to print

调用函数的语法为:

$ runp myfile.py function_name:arg1value,arg2=arg2value

命令和初始代码的概念、语法深受fabric任务系统的启发。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
Google应用程序引擎FreeMarker模板java。安全AccessControlException   在Java中,空字符串(“”)如何存储在内存中?   java如何使用PUT进行创建   java无法构造com的实例。谷歌。云数据存储。钥匙   Java递归中的堆栈溢出错误   java通过结构化设计模式重构冗余代码   javascript使用Selenium IDE 2.9.1上传文件   JAVAutil。扫描仪在Java中将文本文件加载到对象中   这个JAVA程序的时间复杂度是多少   java Springboot+tomcat+ssh=连接链路故障   矢量Java不安全操作   用于Java不同生成代码的协议缓冲区gRPC protobuf生成器   java OSGi为什么我的包命名为“unknown0.0.0”和MANIFEST。MF文件被覆盖了吗?   java日期保持为空(Android)   使用stax解析器java解析xml   java有一种方法可以在运行时确定对象是否是使用Lambdaj创建的。关于()方法?