Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
目前PaddleX CLI的所有命令行参数都处在同一命名空间,并且位置参数被插件安装功能占用,这导致了不同功能之间的“不对称”:看起来像是先有一个安装插件的CLI,然后再把其他功能以可选参数的方式硬塞进CLI,显得不太优雅。例如,执行
paddlex --help
会得到如下结果:其中的位置参数
plugins
看起来像是所有功能都需要用到的公共参数,但实际只有插件安装功能会用到。本PR对PaddleX CLI进行改造,在基本不改动接口的情况下,使各功能尽可能“对称”,看起来更自然。修改后,执行
paddlex --help
会得到如下结果:至少,从上述帮助信息来看,
PLUGIN
只用于--install
,而与其他功能无关。如上所述,本PR所做的修改只能说是“基本不改动接口”,实际上,此前允许的类似
paddlex --install -y PaddleOCR
的用法将不再支持,--install
和插件名之间不再允许插入额外的参数。经过搜索,此前的文档和代码示例中均未涉及到上述用法,所以我认为本PR做的修改还是相对安全的。更优雅的方案可能是使用subparser将不同功能隔离到不同的命名空间,这也符合目前业界大部分同类CLI的实践。不过,考虑到那样修改后的形式可能与现有接口存在较大的不兼容,目前暂不考虑。