Class: MediaWikiVagrant::Hiera

Inherits:
Object
  • Object
show all
Includes:
PluginEnvironment
Defined in:
lib/mediawiki-vagrant/hiera.rb

Overview

Provides a command-line interface for configuration of hiera settings.

Class Method Summary collapse

Instance Method Summary collapse

Methods included from PluginEnvironment

#initialize, #interactive_out?

Class Method Details

.synopsisObject



10
11
12
# File 'lib/mediawiki-vagrant/hiera.rb', line 10

def self.synopsis
  'configures hiera settings'
end

Instance Method Details

#executeObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/mediawiki-vagrant/hiera.rb', line 14

def execute
  options = {
    unset: [],
  }

  opts = OptionParser.new do |o|
    o.banner = 'Usage: vagrant hiera [options] [key] [value]'
    o.separator ''
    o.separator 'Options:'
    o.separator ''

    o.on('--unset NAME', 'Remove a configured key') do |name|
      options[:unset] << name
    end
  end

  argv = parse_options(opts)
  return unless argv

  if options[:unset].any?
    unset_key(options[:unset])
  elsif argv.length == 2
    set_key(*argv)
  else
    @env.ui.error opts
    return 1
  end

  0
end