Class: AnalyticsOps::CLI::Options

Inherits:
Object
  • Object
show all
Defined in:
lib/analytics_ops/cli/options.rb

Overview

Parses and validates command-line options without loading a workspace.

Constant Summary collapse

DEFAULTS =
{
  config: "config/analytics_ops.yml",
  config_explicit: false,
  profile: "production",
  profile_explicit: false,
  format: "human",
  log_level: "warn",
  log_level_explicit: false,
  transport: :grpc,
  transport_explicit: false,
  timeout_explicit: false,
  yes: false,
  noninteractive: false,
  compare: false,
  dimensions: [].freeze,
  metrics: [].freeze,
  filters: [].freeze,
  all_rows: false
}.freeze
SETUP_OPTIONS =
%i[property service_account].freeze
PROPERTY_ID =
/\A\d{1,50}\z/
PROFILE =
/\A[A-Za-z][A-Za-z0-9_]{0,63}\z/
CONNECTION =
/\A[A-Za-z][A-Za-z0-9_-]{0,63}\z/

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(arguments) ⇒ Options

Returns a new instance of Options.



33
34
35
36
37
# File 'lib/analytics_ops/cli/options.rb', line 33

def initialize(arguments)
  @arguments = arguments
  @values = DEFAULTS.transform_values { |value| value.is_a?(Array) ? value.dup : value }
  @explicit_format = nil
end

Instance Attribute Details

#valuesObject (readonly)

Returns the value of attribute values.



31
32
33
# File 'lib/analytics_ops/cli/options.rb', line 31

def values
  @values
end

Instance Method Details

#parse!(command) ⇒ Object



39
40
41
42
43
# File 'lib/analytics_ops/cli/options.rb', line 39

def parse!(command)
  parser.parse!(@arguments)
  validate!(command)
  @values.freeze
end