Class: MediaWikiVagrant::Config
- Includes:
- PluginEnvironment, SettingsPlugin
- Defined in:
- lib/mediawiki-vagrant/config.rb
Overview
Provides a command-line interface for configuration of MediaWiki-Vagrant settings.
Class Method Summary collapse
Instance Method Summary collapse
Methods included from PluginEnvironment
#initialize, #interactive_out?
Class Method Details
.synopsis ⇒ Object
14 15 16 |
# File 'lib/mediawiki-vagrant/config.rb', line 14 def self.synopsis 'configures mediawiki-vagrant settings' end |
Instance Method Details
#execute ⇒ Object
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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/mediawiki-vagrant/config.rb', line 18 def execute = { interactive: false, list: false, required: false, get: [], unset: [], } opts = OptionParser.new do |o| o. = 'Usage: vagrant config [options] [name] [value]' o.separator '' o.separator 'Options:' o.separator '' o.on('--all', 'Configure all settings') do [:interactive] = true end o.on('--required', 'Configure only required settings') do [:interactive] = true [:required] = true end o.on('--list', 'List all settings') do [:list] = true end o.on('--get NAME', 'Get a configured setting') do |name| [:get] << name end o.on('--unset NAME', 'Remove a configured setting') do |name| [:unset] << name end end argv = (opts) return unless argv if [:list] list_settings elsif [:interactive] interactively_configure() elsif argv.length == 2 configure_setting(*argv) elsif [:get].any? || [:unset].any? get_settings([:get]) unset_settings([:unset]) else @env.ui.error opts return 1 end 0 end |