Python:为什么我的Click CLI没有执行所需的功能?

Python:为什么我的Click CLI没有执行所需的功能?,python,python-3.x,python-click,Python,Python 3.x,Python Click,我有一个功能与点击装饰。该函数的全部目的是将CLI选项添加到tq_oex_交换类正在完成的工作中 @click.command() @click.option('-input_file', help='The input file to process') @click.option('-output_file', help='The output file to create') @click.option('-part_num_col', help='The column containin

我有一个功能与点击装饰。该函数的全部目的是将CLI选项添加到tq_oex_交换类正在完成的工作中

@click.command()
@click.option('-input_file', help='The input file to process')
@click.option('-output_file', help='The output file to create')
@click.option('-part_num_col', help='The column containing the part numbers')
@click.option('-summate_cols', help='The columns to summate')
def run(input_file, output_file, part_num_col, summate_cols):
    from re import split
    summate_cols = [int(i) for i in split(',', summate_cols)]
    part_num_col = int(part_num_col)
    teek = tq_oex_interchange()
    click.echo("Working...")
    teek.scan_file(input_file, output_file, part_num_col, summate_cols)
但是,当我使用命令执行脚本时

python tq_oex.py -input_file C:\Users\barnej78\Desktop\test_0.csv -output_file C:\Users\barnej78\Desktop\cmd.csv -part_num_col 3 -summate_cols 5,6
没有发生任何事情,甚至没有执行click echo

另外,

python tq_oex.py --help
也什么都不做

这些命令都没有错误或异常输出


我做错了什么?

您能从这里成功运行示例代码吗

我会从这个开始,确保它能工作。然后使用单击测试文档为其编写测试:

这样,当你开始调整它,你可以运行测试,看看什么打破

对于Click应用程序,我通常从一个简单的参数开始,然后添加另一个参数以确保它仍然有效:

@click.command()
@click.argument('input_file')
def run_files(input_file):
    click.echo(input_file)
然后在此基础上添加一个选项:

@click.command()
@click.argument('input_file')
@click.option('--output_file', help='The output file to create')
def run_files(input_file, output_file):
    click.echo(input_file, output_file)
出于调试目的,我也喜欢设置默认值:

def run_files(input_file='/path/to/input_file',
              output_file='/path/to/output_file'):
    click.echo(input_file, output_file)

这是整个剧本吗?