Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature]添加Click-Like构造方式 #13

Closed
2 tasks done
RF-Tar-Railt opened this issue Feb 10, 2022 · 4 comments
Closed
2 tasks done

[Feature]添加Click-Like构造方式 #13

RF-Tar-Railt opened this issue Feb 10, 2022 · 4 comments
Labels
enhancement New feature or request

Comments

@RF-Tar-Railt
Copy link
Member

检查

  • 新特性的目的明确
  • 我已经阅读了文档 the wiki 并且找不到类似特性

Feature

概要
用类似于Click构造command的方式构造一个Alconna

是否已有相关实现

command_decorate = AlconnaDecorator()
@command_decorate()
@command_decorate.option("--foo", Args["bar":str])
def test(bar: str):
    ...

其他内容
1.该方式不支持传入多类命令头
2.该方式装饰的函数暂定为main_args_action
3.该方式或许有其他更简易的相关实现

@RF-Tar-Railt RF-Tar-Railt added the enhancement New feature or request label Feb 10, 2022
@RF-Tar-Railt
Copy link
Member Author

该特性或许需要接入Executor或者ParserHandler

@RF-Tar-Railt
Copy link
Member Author

该方法装饰的函数会经过一个parser_func来完成参数分配任务与函数执行,其有四个参数,一是exec_target,是装饰的函数,二是all_args,解析到的所有参数,三是extra_args,装饰函数可能需要的参数,四是loop,负责可能的异步处理;
内部实现随意,比如要用bcc就在里面塞个Executor(

@RF-Tar-Railt
Copy link
Member Author

  1. @deco.argument用来注册主参数
  2. parser_func应在参数分配失败时报错

@RF-Tar-Railt
Copy link
Member Author

0.6 已加入

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant