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



242
243
244
# File 'lib/ass_launcher/enterprise/cli/spec_dsl.rb', line 242

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 its subparameters. Subparameters defines in the block.



180
181
182
183
# File 'lib/ass_launcher/enterprise/cli/spec_dsl.rb', line 180

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



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



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



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 its subparameters. Subparameters defines in the block.



160
161
162
163
# File 'lib/ass_launcher/enterprise/cli/spec_dsl.rb', line 160

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

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

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.



214
215
216
217
# File 'lib/ass_launcher/enterprise/cli/spec_dsl.rb', line 214

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 its subparameters. Subparameters defines in the block.



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.

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.

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

Define Parameters::PathTwice parameter and its subparameters. Subparameters defines in the block.



142
143
144
145
# File 'lib/ass_launcher/enterprise/cli/spec_dsl.rb', line 142

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



236
237
238
# File 'lib/ass_launcher/enterprise/cli/spec_dsl.rb', line 236

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.



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

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 its subparameters. Subparameters defines in the block.



151
152
153
154
# File 'lib/ass_launcher/enterprise/cli/spec_dsl.rb', line 151

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 its subparameters. Subparameters defines in the block.



170
171
172
173
# File 'lib/ass_launcher/enterprise/cli/spec_dsl.rb', line 170

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



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



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



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.



190
191
192
193
# File 'lib/ass_launcher/enterprise/cli/spec_dsl.rb', line 190

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



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

def web
  :web
end