Module: Mixlib::CLI::ClassMethods

### Home Classes Methods

### In Files

- lib/mixlib/cli.rb

### Methods

- #banner
- #option
- #options
- #options=
- #use_separate_default_options
- #use_separate_defaults?

### Files

- LICENSE
- NOTICE
- README.rdoc

### Class/Module Index

Quicksearch

- Mixlib
- Mixlib::CLI
- Mixlib::CLI::ClassMethods

No matching classes.

# Mixlib::CLI::ClassMethods

### Public Instance Methods

banner(bstring=nil) click to toggle source

Change the banner. Defaults to:

    Usage: #{0} (options)

### Parameters

bstring<String> | The string to set the banner to

### Returns

@banner<String> | The current banner

    # File lib/mixlib/cli.rb, line 95
    def banner(bstring=nil)
      if bstring
        @banner = bstring
      else
        @banner ||= "Usage: #{$0} (options)"
        @banner
      end
    end

option(name, args) click to toggle source

Add a command line option.

### Parameters

name<Symbol> | The name of the option to add
args<Hash> | A hash of arguments for the option, specifying how it should be parsed.

### Returns

true | Always returns true.

    # File lib/mixlib/cli.rb, line 60
    def option(name, args)
      @options ||= {}
      raise(ArgumentError, "Option name must be a symbol") unless name.kind_of?(Symbol)
      @options[name.to_sym] = args
    end

options() click to toggle source

Get the hash of current options.

### Returns

@options<Hash> | The current options hash.

    # File lib/mixlib/cli.rb, line 70
    def options
      @options ||= {}
      @options
    end

options=(val) click to toggle source

Set the current options hash

### Parameters

val<Hash> | The hash to set the options to

### Returns

@options<Hash> | The current options hash.

    # File lib/mixlib/cli.rb, line 82
    def options=(val)
      raise(ArgumentError, "Options must recieve a hash") unless val.kind_of?(Hash)
      @options = val
    end

use_separate_default_options(true_or_false) click to toggle source

When this setting is set to `true`, default values supplied to the mixlib-cli DSL will be stored in a separate Hash

    # File lib/mixlib/cli.rb, line 45
    def use_separate_default_options(true_or_false)
      @separate_default_options = true_or_false
    end

use_separate_defaults?() click to toggle source

    # File lib/mixlib/cli.rb, line 49
    def use_separate_defaults?
      @separate_default_options || false
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.