You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
此版本为长期支持版本 (LTS), 也是 2.0 版本前的最后一个版本
破坏性改动:
ShortcutArgs
不再需要options
, 其合并至args
Alconna.parse
移除参数interrupt
, 由CompSession
替代NEPattern
0.5 以上版本tarina
替代部分功能DataCollectionContainer
,Analyser
,handle_xxx
和analyser_xxx
等移动至
arclet.alconna._internal
DataCollectionContainer
重命名为Argv
Argv.config
移出为独立函数argv_config
Argv.text_sign
现在是Argv.to_text
, 其返回值为str | None
新增:
Option
新增参数compact
, 允许选项名后的第一个参数紧随其头部Option
新增参数default
, 允许设置选项的默认值:OptionResult
, 除非其为None
OptionResult
会被直接使用OptionResult
Subcommand
新增参数default
, 允许设置子命令的默认值SubcommandResult
, 除非其为None
SubcommandResult
会被直接使用SubcommandResult
CommandMeta
与Namespace
新增compact
属性, 允许命令传入的第一个参数紧随其头部Namespace
新增to_text
属性, 其与Argv.to_text
一致CompSession
, 用于交互式命令补全session.available
: 表示当前补全会话是否可用session.current()
: 当前选中的补全选项的文本session.tab([, offset])
: 切换补全选项session.enter([, content])
: 确认当前补全选项Alconna
的名字与前缀无传入时,取用 sys.argv[0] 作为其名字Alconna
现支持__call__
, 即直接调用实例; 当命令名与 sys.argv[0] 接近时, 传入命令不需要输入命令头Action
改动, 现在Action
功能更接近于argparse
:store
: 默认的 action, 存放...
或default
的值store_value
,store_true
,store_false
: 存放特殊值append
: 追加...
或default
的值append_value
: 追加特殊值count
: 计数store_xxx
,count
: 最新的 args 结果会覆盖上一次append_xxx
: 此次的 args 结果会与之前的合并成列表set_default_argv_type
函数, 用于设置默认的Argv
类型CommandMeta.example
现在会将$
替换为可能的命令前缀Completion
选项增加别名'?'
改进:
name
与requires
合成的dest
也会去掉name
的前缀Argv
不再是Analyser
的属性, 而是其方法的传入参数compile
函数现在作为Alconna
的方法ShortcutArgs
增加fuzzy
参数, 用于指定该快捷命令是否允许后随参数, 默认为True
{%X_n}
来引用传入的快捷命令的第 n 个参数{*(SEP)}
来引用传入的快捷命令的所有参数, 其中 SEP 为可选的分隔符set_default
的arg
,option
,subcommand
合并为path
, 原参数仍可用Arg
中name
的后缀标识符不强制需要';'
作为分割, 即foo;?
与foo?
等价Argv.preprocessor
与Argv.filter_out
现在接收 type 而不是 strAlconna.reset_behaviors
修复:
anti args
的 bugFormatter.remove
的 bugThis discussion was created from the release Alconna 1.7.0.
Beta Was this translation helpful? Give feedback.
All reactions