https://click.palletsprojects.com/en/7.x/commands/

多个命令行可以嵌套

@click.group()
@click.option('--debug/--no-debug', default=False)
def cli(debug):click.echo('Debug mode is %s' % ('on' if debug else 'off'))@cli.command()  # @cli, not @click!
def sync():click.echo('Syncing')
$ tool.py
Usage: tool.py [OPTIONS] COMMAND [ARGS]...Options:--debug / --no-debug--help                Show this message and exit.Commands:sync$ tool.py --debug sync
Debug mode is on
Syncing

传递参数

Nested Handling and Contexts

@click.group()
@click.option('--debug/--no-debug', default=False)
@click.pass_context
def cli(ctx, debug):# ensure that ctx.obj exists and is a dict (in case `cli()` is called# by means other than the `if` block below)ctx.ensure_object(dict)ctx.obj['DEBUG'] = debug@cli.command()
@click.pass_context
def sync(ctx):click.echo('Debug is %s' % (ctx.obj['DEBUG'] and 'on' or 'off'))if __name__ == '__main__':cli(obj={})

Decorating Commands

from functools import update_wrapperdef pass_obj(f):@click.pass_contextdef new_func(ctx, *args, **kwargs):return ctx.invoke(f, ctx.obj, *args, **kwargs)return update_wrapper(new_func, f)

click Commands and Groups相关推荐

  1. python click

    click group实例 click quickstart click Setuptools Integration click Parameters click option click Comm ...

  2. [转载] python docopt_比较Python命令行解析库– Argparse,Docopt和Click

    参考链接: 使用Python的argparse创建命令行实用程序 python docopt About a year ago I began a job where building command ...

  3. VSTO Ribbons的完整介绍

    Ribbons are the modern way to help users find, understand, and use commands efficiently and directly ...

  4. oracle fra空间不足,ORACLE 基础解决方案1_扩大FRA区

    ORACLE 基础解决方案(一) Reviewing the Database Architecture Reviewing the Database Architecture 回顾数据库结构 For ...

  5. aws v2.2.exe_如何在AWS Elastic Beanstalk上部署Rails 5.2 PostgreSQL应用

    aws v2.2.exe by Evrim Persembe 通过埃夫里姆·佩塞姆贝 如何在AWS Elastic Beanstalk上部署Rails 5.2 PostgreSQL应用 (How to ...

  6. sql azure 语法_Azure SQL Server自动故障转移组

    sql azure 语法 In this article, we will review how to set up auto-failover groups in Azure SQL Server ...

  7. aws rds监控慢sql_使用本机备份的AWS RDS SQL Server迁移

    aws rds监控慢sql In this article, we will review how to migrate database from on-premises SQL Server in ...

  8. aws rds监控慢sql_在AWS RDS SQL Server上的SSAS中部署表格数据库

    aws rds监控慢sql In this article, we are going to explore Analysis Service for AWS RDS SQL Server in de ...

  9. aws rds 加密_AWS RDS SQL Server中的透明数据加密(TDE)

    aws rds 加密 In this article, we will review Transparent Data Encryption (TDE) in AWS RDS SQL Server. ...

最新文章

  1. 炉石传说 C# 设计文档(序)
  2. C#中,什么时候用yield return
  3. 偏置面命令_UG10.0 入门图文教程——同步建模之移动面
  4. 无法启动程序因为计算机中丢失礼包,Win10开机提示“计算机中丢失mfc110u.dll”的解决方法...
  5. FileZilla 服务器端win server2008以上的配置
  6. 临时表、表变量、CTE的比较
  7. 101.接收上游响应的缓存处理流程
  8. 【转】windows操作系统同步 (Critical Section,Mutex,Semaphore,Event Object,Interlocked Variable)...
  9. eclipse 快捷调整字体_eclipse字体大小设置快捷键
  10. 【结课报告】游戏中的知识产权
  11. 软件著作权统计源程序量,统计php代码行数
  12. 小米盒子 计算机共享,小米盒子如何通过局域网共享安装软件
  13. python 爬取生意参谋数据_如何爬取生意参谋数据?是不是违规操作?
  14. 用计算机信息术语感恩老师,【感谢老师的对联师恩难忘的对联】_感谢师恩、感恩老师的对联—经典用语大全...
  15. C++11线程的生命周期
  16. 消费金融公司可开展哪些业务类型?
  17. .NET 2.0 调用FFMPEG
  18. mysql 存储百分数_mysql中如何存储百分数
  19. 古代神话体系--古希腊、罗马、北欧和中国
  20. Excel批量插入多个空行-VBA实现

热门文章

  1. c语言结果输出10遍,C语言 如何实现输出这样一系列输出结果
  2. java 去掉大量if else_Java中大量if...else语句的消除替代方案
  3. python 爬虫源码 selenium并存储数据库_使用pythonSelenium爬取内容并存储MySQL数据库的实例图解...
  4. sprintf函数的用法_我在C++项目中对于宏的一些用法
  5. python知识点查阅
  6. qml入门学习(二):引入js文件
  7. C++新特性探究(六):auto
  8. linux shell指令 amp,shell入门基础amp;常见命令及用法
  9. 如何来评测服务器性能,Web实战之:服务器性能的测量评价
  10. python 全局变量_python程序中用类变量代替global 定义全局变量