pub
包管理器有很多命令,用Dart语言编写。
这是否可以实现相同的功能(子命令)而不需要太多努力?
是否有任何库可以加快控制台应用程序中各种命令和选项的开发?
嗯,例如,我想用以下命令(带选项和参数)实现一个程序:
如何快速为他们开发处理程序?
答案 0 :(得分:3)
这就是args包的用途。
答案 1 :(得分:1)
如果您不介意开发控制台应用程序的基础,那么遵循一些specification
而不是一种可能的方法来快速轻松地开发控制台应用程序的基础就是使用包{{ 1}}。
用法(示例):
args_helper
命令规范(示例)。
Usage: test command [options] [arguments]
List of available commands:
action add Create the controller action.
controller create Create the controller.
create action Create the controller action.
create controller Create the controller.
create project Create the web project.
create view Create the view.
project create Create the web project.
view create Create the view.
源代码(示例):
name: test
description: Test program
commands:
create action:
aliases: [action add]
description: Create the controller action.
options:
name:
abbr: n
help: Name for the action.
required: true
controller:
abbr: c
help: Name for the controller.
required: true
view:
abbr: v
isFlag: true
defaultsTo: true
help: Indicates that need to create the view.
create project:
aliases: [project create]
description: Create the web project.
options:
init:
abbr: i
isFlag: true
defaultsTo: true
help: Indicates that need to initialize the project.
rest:
allowMultiple: false
help: Name of the project.
name: project_name
required: true
create controller:
aliases: [controller create]
description: Create the controller.
rest:
allowMultiple: false
help: Name of the controller.
name: controller_name
required: true
options:
create view:
aliases: [view create]
description: Create the view.
options:
controller:
abbr: c
help: Name of the controller.
required: true
name:
abbr: n
help: Name for the view.
required: true