Module: AssLauncher::Enterprise::Cli::Parameters Private

Included in:
StringParam
Defined in:
lib/ass_launcher/enterprise/cli/parameters.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

1C Enterprise cli parameters Fuckin 1C have very obscure cli api Parameters may have subparameters. All parameters and subparameters expects argument or not. Some parameters may be modified with + or - or other values like this: /Parm or /Param+ or /Param- or /Param:date:time.

For implement binding parameters and subparameters, parameter have parent propery. If parent property is nil it is root parameter and subpurameter if else

Defined Under Namespace

Classes: AllParameters, Chose, Flag, ParametersList, Path, PathTwice, Skip, SkippedError, StringParam, Switch

Constant Summary collapse

DEFAULT_OPTIONS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Options for parameter

{
  required: false,
  value_validator: nil,
  switch_list: nil,
  chose_list: nil,
  switch_value: nil
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#binary_matcherBinaryMatcher (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

1C binary type and version for which parameter defined

Returns:



36
37
38
# File 'lib/ass_launcher/enterprise/cli/parameters.rb', line 36

def binary_matcher
  @binary_matcher
end

#descObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameter help message

Returns:

  • string



32
33
34
# File 'lib/ass_launcher/enterprise/cli/parameters.rb', line 32

def desc
  @desc
end

#groupSymbol (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameter group for build cli api help

Returns:

  • (Symbol)


39
40
41
# File 'lib/ass_launcher/enterprise/cli/parameters.rb', line 39

def group
  @group
end

#modesArray<Symbol> (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

1C binary run mode for which parameter defined. see DEFINED_MODES

Returns:

  • (Array<Symbol>)


43
44
45
# File 'lib/ass_launcher/enterprise/cli/parameters.rb', line 43

def modes
  @modes
end

#nameObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameter name like it define in 1C cli api Name may start with ‘/’ or ‘-’ key. Example: /Parameter or -subpurameter

Returns:

  • string



29
30
31
# File 'lib/ass_launcher/enterprise/cli/parameters.rb', line 29

def name
  @name
end

#optionsHash (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Options see DEFAULT_OPTIONS

Returns:

  • (Hash)


49
50
51
# File 'lib/ass_launcher/enterprise/cli/parameters.rb', line 49

def options
  @options
end

#parentObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parent parameter for subpurameter

Returns:

  • kinde of [String]



46
47
48
# File 'lib/ass_launcher/enterprise/cli/parameters.rb', line 46

def parent
  @parent
end

Instance Method Details

#add_child(param) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Add subparameter into #childs array

Parameters:



184
185
186
# File 'lib/ass_launcher/enterprise/cli/parameters.rb', line 184

def add_child(param)
  childs << param
end

#child?(expected_parent) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns true if it’s child of expected_parent parameter

Parameters:

  • expected_parent

    kinde of [StringParam]

Returns:

  • (Boolean)


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

def child?(expected_parent)
  return false if root?
  parent == expected_parent
end

#childsArray

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Array of subparameters

Returns:

  • (Array)


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

def childs
  @childs ||= []
end

#chose_listObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Wrapper for #options



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

def chose_list
  options[:chose_list]
end

#deepFixnum

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns deep parameter in hierarchy tree

Returns:

  • (Fixnum)


88
89
90
# File 'lib/ass_launcher/enterprise/cli/parameters.rb', line 88

def deep
  parents.size
end

#full_nameString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns parameter full name. Full name composed from full_name of all #parents parameters

Returns:



74
75
76
77
# File 'lib/ass_launcher/enterprise/cli/parameters.rb', line 74

def full_name
  return name if root?
  "#{parent.full_name}#{name}"
end

#match?(binary_wrapper, run_mode) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return true if parameter defined for binary_wrapper and run_mode

Parameters:

Returns:

  • (Boolean)


55
56
57
# File 'lib/ass_launcher/enterprise/cli/parameters.rb', line 55

def match?(binary_wrapper, run_mode)
  binary_matcher.match?(binary_wrapper) && modes.include?(run_mode)
end

#match_version?(version) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return true if parameter defined for version

Parameters:

  • version (Gem::Version)

Returns:

  • (Boolean)


61
62
63
# File 'lib/ass_launcher/enterprise/cli/parameters.rb', line 61

def match_version?(version)
  binary_matcher.requirement.satisfied_by? version
end

#parentsArray

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Array of parent parameters

Returns:

  • (Array)


81
82
83
84
# File 'lib/ass_launcher/enterprise/cli/parameters.rb', line 81

def parents
  return [] if root?
  parent.parents << parent
end

#required?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Wrapper for #options

Returns:

  • (Boolean)


139
140
141
# File 'lib/ass_launcher/enterprise/cli/parameters.rb', line 139

def required?
  options[:required]
end

#restrict_from(version) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Restricts parameter from version and do it recursively for all subparameters from #childs array

Parameters:

  • version (Gem::Version)


191
192
193
194
195
196
# File 'lib/ass_launcher/enterprise/cli/parameters.rb', line 191

def restrict_from(version)
  restrict_childs(version)
  binary_matcher.requirement =
    restrict_v(binary_matcher.requirement,
               version) if match_version? version
end

#root?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns true if haven’t #parent parameter

Returns:

  • (Boolean)


93
94
95
# File 'lib/ass_launcher/enterprise/cli/parameters.rb', line 93

def root?
  parent.nil?
end

#switch_listObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Wrapper for #options



119
120
121
# File 'lib/ass_launcher/enterprise/cli/parameters.rb', line 119

def switch_list
  options[:switch_list]
end

#switch_valueObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Wrapper for #options



134
135
136
# File 'lib/ass_launcher/enterprise/cli/parameters.rb', line 134

def switch_value
  options[:switch_value] || proc { |value| value }
end

#to_args(value) ⇒ Array<String>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns self with value as 1C:Enterprise CLI argumets array

Examples:

param.name #=> "/Parm"
param.to_args 'value' #=> ["/Param", "value"]

Returns:



114
115
116
# File 'lib/ass_launcher/enterprise/cli/parameters.rb', line 114

def to_args(value)
  [key(value).to_s, value(value).to_s]
end

#to_sObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

:nodoc:



105
106
107
# File 'lib/ass_launcher/enterprise/cli/parameters.rb', line 105

def to_s
  name.to_s
end

#to_symObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

:nodoc:



66
67
68
# File 'lib/ass_launcher/enterprise/cli/parameters.rb', line 66

def to_sym
  name.downcase.to_sym
end

#usageObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Builds usage message



165
166
167
# File 'lib/ass_launcher/enterprise/cli/parameters.rb', line 165

def usage
  fail NotImplementedError
end

#value_validatorObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Wrapper for #options



129
130
131
# File 'lib/ass_launcher/enterprise/cli/parameters.rb', line 129

def value_validator
  options[:value_validator] ||  proc { |value| value }
end