Module: AssLauncher::Enterprise::Cli::SpecDsl

Includes:
DslHelpers
Included in:
AssLauncher::Enterprise::CliDef
Defined in:
lib/ass_launcher/enterprise/cli/spec_dsl.rb,
lib/ass_launcher/enterprise/cli/spec_dsl/dsl_helpers.rb

Overview

DSL for describe 1C:Enterprise command-line interface

Defined Under Namespace

Modules: DslHelpers

Instance Method Summary collapse

Methods included from DslHelpers

#_t, #described_modes, #enterprise_versions, #parameters, #parameters_groups

Instance Method Details

#change(name, &block) ⇒ Object

Change specifications of subparameters for already specified parameter name



240
241
242
# File 'lib/ass_launcher/enterprise/cli/spec_dsl.rb', line 240

def change(name, &block)
  change_param name, &block
end

#chose(name, desc, *clients, **options, &block) ⇒ Cli::Parameters::Chose

Note:

use helper #chose_list for build :chose_list option

Define Parameters::Chose parameter and him subparameters. Subparameters defines in the block.

Parameters:

Returns:



178
179
180
181
# File 'lib/ass_launcher/enterprise/cli/spec_dsl.rb', line 178

def chose(name, desc, *clients, **options, &block)
  new_param(Parameters::Chose, name, desc,
            clients, options, &block)
end

#define_group(name, desc, priority) ⇒ Object

Define CLI parameters group

Parameters:

  • name (Symbol)

    group name

  • desc (String)

    description for group

  • priority (Fixnum)

    priority for parameters group for build help message



34
35
36
37
# File 'lib/ass_launcher/enterprise/cli/spec_dsl.rb', line 34

def define_group(name, desc, priority)
  parameters_groups[name.to_sym] =
    { desc: _t(desc), priority: priority }
end

#describe_mode(mode, desc, banner) ⇒ Object

Describe run modes specifications

Parameters:

  • mode (Symbol)

    1C:Enterprise run mode.

  • desc (String)

    description for run mode

  • banner (String)

    bunner for usage



24
25
26
27
# File 'lib/ass_launcher/enterprise/cli/spec_dsl.rb', line 24

def describe_mode(mode, desc, banner)
  fail "Undefined mode: #{mode}" unless defined_modes.include? mode
  described_modes[mode] = { desc: _t(desc), banner: _t(banner) }
end

#enterprise_version(v) ⇒ Object

Define 1C:Enterprise version for defined CLI specifications

Parameters:

  • v (String)

    1C:Enterprise verion string



15
16
17
18
# File 'lib/ass_launcher/enterprise/cli/spec_dsl.rb', line 15

def enterprise_version(v)
  reset_all
  add_enterprise_versions Gem::Version.new(v)
end

#flag(name, desc, *clients, **options, &block) ⇒ Cli::Parameters::Flag

Define Parameters::Flag parameter and him subparameters. Subparameters defines in the block.

Parameters:

Returns:



158
159
160
161
# File 'lib/ass_launcher/enterprise/cli/spec_dsl.rb', line 158

def flag(name, desc, *clients, **options, &block)
  new_param(Parameters::Flag, name, desc,
            clients, **options, &block)
end

#group(key, &block) ⇒ Object

Block to grouping CLI parameters into parameters group. Group must be defined as #define_group

Parameters:

  • key (Symbol)

    group name

Raises:

  • if passed undefined group

  • if call without block



80
81
82
83
84
85
86
# File 'lib/ass_launcher/enterprise/cli/spec_dsl.rb', line 80

def group(key, &block)
  fail_if_wrong_group(key)
  fail 'Block required' unless block_given?
  self.current_group = key
  instance_eval(&block)
  reset_group
end

#mode(*modes, &block) ⇒ Object

Block to define CLI parameters for run modes

Parameters:

  • modes (Array<Symbol>)

    run modes wich CLI parameters defined

Raises:

  • if passed invalid 1C:Enterprise run mode

  • if call without block



62
63
64
65
66
67
68
# File 'lib/ass_launcher/enterprise/cli/spec_dsl.rb', line 62

def mode(*modes, &block)
  fail_if_wrong_modes modes
  fail 'Block required' unless block_given?
  self.current_modes = modes
  instance_eval(&block)
  reset_modes
end

#num(name, desc, *clients, **options, &block) ⇒ Cli::Parameters::StringParam

Note:

It initialize :value_validator option with Proc

Define Parameters::StringParam parameter suitable for validation numeric argument. Subparameters defines in the block.

Parameters:

Returns:



212
213
214
215
# File 'lib/ass_launcher/enterprise/cli/spec_dsl.rb', line 212

def num(name, desc, *clients, **options, &block)
  options[:value_validator] = num_value_validator(name)
  string(name, desc, *clients, **options, &block)
end

#path(name, desc, *clients, **options, &block) ⇒ Cli::Parameters::Path

Define Parameters::Path parameter and him subparameters. Subparameters defines in the block.

Parameters:

Returns:



115
116
117
118
# File 'lib/ass_launcher/enterprise/cli/spec_dsl.rb', line 115

def path(name, desc, *clients, **options, &block)
  new_param(Parameters::Path, name, desc,
            clients, **options, &block)
end

#path_exist(name, desc, *clients, **options, &block) ⇒ Cli::Parameters::Path

Path with exist validation.

Parameters:

Returns:

See Also:



124
125
126
127
# File 'lib/ass_launcher/enterprise/cli/spec_dsl.rb', line 124

def path_exist(name, desc, *clients, **options, &block)
  path(name, desc, *clients, options.merge(must_be: :exist),
       &block)
end

#path_not_exist(name, desc, *clients, **options, &block) ⇒ Cli::Parameters::Path

Path with not exist validation.

Parameters:

Returns:

See Also:



133
134
135
136
137
# File 'lib/ass_launcher/enterprise/cli/spec_dsl.rb', line 133

def path_not_exist(name, desc, *clients, **options, &block)
  path(name, desc, *clients,
       options.merge(must_be: :not_exist),
       &block)
end

#path_twice(name, desc, *clients, **options, &block) ⇒ Cli::Parameters::PathTwice



140
141
142
143
# File 'lib/ass_launcher/enterprise/cli/spec_dsl.rb', line 140

def path_twice(name, desc, *clients, **options, &block)
  new_param(Parameters::PathTwice, name, desc,
            clients, **options, &block)
end

#restrict(name) ⇒ nil

Restrict already specified parameter name recursively with all subparameters

Parameters:

  • name (String)

    name of 1C:Enterprise CLI parameter

Returns:

  • (nil)


234
235
236
# File 'lib/ass_launcher/enterprise/cli/spec_dsl.rb', line 234

def restrict(name)
  restrict_params(name, current_version)
end

#skip(name, desc = '') ⇒ Cli::Parameters::Skip

Stub for skipped parameter. Many 1C:Enterprise CLI parameters is not imprtant for describe in CliSpec. For define it fact, you can use this method.

Parameters:

Returns:



249
250
251
252
253
254
255
256
# File 'lib/ass_launcher/enterprise/cli/spec_dsl.rb', line 249

def skip(name, desc = '')
  p = Parameters::Skip.new(name, desc,
                           new_binary_matcher([:skip]),
                           :skip,
                           [:skip], current_parent)
  add_parameter p
  p
end

#string(name, desc, *clients, **options, &block) ⇒ Cli::Parameters::StringParam

Define Parameters::StringParam parameter and him subparameters. Subparameters defines in the block.

Parameters:

Returns:



149
150
151
152
# File 'lib/ass_launcher/enterprise/cli/spec_dsl.rb', line 149

def string(name, desc, *clients, **options, &block)
  new_param(Parameters::StringParam, name, desc,
            clients, **options, &block)
end

#switch(name, desc, *clients, **options, &block) ⇒ Cli::Parameters::Switch

Note:

use helper #switch_list for build :switch_list option

Define Parameters::Switch parameter and him subparameters. Subparameters defines in the block.

Parameters:

Returns:



168
169
170
171
# File 'lib/ass_launcher/enterprise/cli/spec_dsl.rb', line 168

def switch(name, desc, *clients, **options, &block)
  new_param(Parameters::Switch, name, desc,
            clients, options, &block)
end

#switch_list(**options) ⇒ Object Also known as: chose_list

Build switch or chose list for CLI parameters clases: Parameters::Switch or Parameters::Chose

Parameters:

  • options (Hash)

    :key is argument for CLI parameter, value is description for help message



98
99
100
101
102
# File 'lib/ass_launcher/enterprise/cli/spec_dsl.rb', line 98

def switch_list(**options)
  options.each_key do |k|
    options[k] = _t(options[k])
  end
end

#thickSymbol

Return 1C client identifier see BinaryMatcher::ALL_CLIENTS

Returns:

  • (Symbol)

    :thick



42
43
44
# File 'lib/ass_launcher/enterprise/cli/spec_dsl.rb', line 42

def thick
  :thick
end

#thinSymbol

Return 1C client identifier see BinaryMatcher::ALL_CLIENTS

Returns:

  • (Symbol)

    :thin



48
49
50
# File 'lib/ass_launcher/enterprise/cli/spec_dsl.rb', line 48

def thin
  :thin
end

#url(name, desc, *clients, **options, &block) ⇒ Cli::Parameters::StringParam

Note:

It initialize :value_validator option with Proc

Define Parameters::StringParam parameter suitable for validation URL argument. Subparameters defines in the block.

Parameters:

Returns:



188
189
190
191
# File 'lib/ass_launcher/enterprise/cli/spec_dsl.rb', line 188

def url(name, desc, *clients, **options, &block)
  options[:value_validator] = url_value_validator(name)
  string(name, desc, *clients, **options, &block)
end

#webSymbol

Return 1C client identifier see BinaryMatcher::ALL_CLIENTS

Returns:

  • (Symbol)

    :web



54
55
56
# File 'lib/ass_launcher/enterprise/cli/spec_dsl.rb', line 54

def web
  :web
end