-1

以下ddl

action 'ant', :description => "Runs ant in the application directory" do
  input :application,
      :prompt      => "Application(s)",
      :description => "Application's instance name(s)",
      :type        => :string,
      :validation  => '^[a-z0-9_,\-]+$',
      :maxlength   => 500,
      :optional    => false

可以在代理内部使用来获取命令行参数application

  # entry point for the ant target
  action 'ant' do
    # find eligible applications
    applications = request[:application].split(',').select{|a| valid_application?(a) }

命令命令可以启动mco <agentname> -a applicationname1,applicationname2等等。发行mco <agentname> --help给了我:

$ mco ehyp --help
Manage an <internal> application
Application Options
    -a, --application APPLICATION    Application to manage

我没有找到-aor--application和之间的“链接” request[:application]。它在哪里定义了如何解释这些命令行开关?

4

1 回答 1

0

它在MCollective::Application您定义的地方定义:

option :application,
     :description => 'Application to manage',
     :arguments   => ['-a', '--application APPLICATION'],
     :required    => true

option :destination,
     :description => 'Ant target ("destination") to call',
     :arguments   => ['-d', '--destination TARGET'],
     :required    => true
于 2018-03-09T12:11:24.717 回答