Class: Nugrant::Vagrant::V2::Command::RestrictedKeys
- Inherits:
-
Object
- Object
- Nugrant::Vagrant::V2::Command::RestrictedKeys
- Defined in:
- lib/nugrant/vagrant/v2/command/restricted_keys.rb
Class Method Summary collapse
Instance Method Summary collapse
- #create_parser ⇒ Object
- #execute ⇒ Object
- #help(parser) ⇒ Object
-
#initialize(arguments, environment) ⇒ RestrictedKeys
constructor
A new instance of RestrictedKeys.
Constructor Details
#initialize(arguments, environment) ⇒ RestrictedKeys
Returns a new instance of RestrictedKeys.
13 14 15 16 17 |
# File 'lib/nugrant/vagrant/v2/command/restricted_keys.rb', line 13 def initialize(arguments, environment) super(arguments, environment) @show_help = false end |
Class Method Details
.synopsis ⇒ Object
9 10 11 |
# File 'lib/nugrant/vagrant/v2/command/restricted_keys.rb', line 9 def self.synopsis "prints list of restricted keys for method access" end |
Instance Method Details
#create_parser ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/nugrant/vagrant/v2/command/restricted_keys.rb', line 19 def create_parser() return OptionParser.new do |parser| parser. = "Usage: vagrant user restricted-keys" parser.separator "" parser.separator "Available options:" parser.separator "" parser.on("-h", "--help", "Prints this help") do @show_help = true end parser.separator "" parser.separator "Prints keys that cannot be accessed using the method access syntax\n" + "(`config.user.<key>`). Use array access syntax (`config.user['<key>']`)\n" + "if you really want to use of the restricted keys.\n" end end |
#execute ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/nugrant/vagrant/v2/command/restricted_keys.rb', line 38 def execute parser = create_parser() arguments = (parser) return help(parser) if @show_help @env.ui.info("The following keys are restricted, i.e. that method access (`config.user.<key>`)", :prefix => false) @env.ui.info("will not work. If you really want to use a restricted key, use array access ", :prefix => false) @env.ui.info("instead (`config.user['<key>']`).", :prefix => false) @env.ui.info("", :prefix => false) @env.ui.info("You can run `vagrant user parameters` to check if your config currently defines", :prefix => false) @env.ui.info("one or more restricted keys shown below.", :prefix => false) @env.ui.info("", :prefix => false) restricted_keys = Helper::get_restricted_keys() @env.ui.info(restricted_keys.sort().join(", "), :prefix => false) end |
#help(parser) ⇒ Object
57 58 59 |
# File 'lib/nugrant/vagrant/v2/command/restricted_keys.rb', line 57 def help(parser) @env.ui.info(parser.help, :prefix => false) end |