Module: ChefApply::CLI::Options

Included in:
ChefApply::CLI
Defined in:
lib/chef_apply/cli/options.rb

Constant Summary collapse

T =
ChefApply::Text.cli
TS =
ChefApply::Text.status

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/chef_apply/cli/options.rb', line 36

def self.included(klass)
  klass.banner T.description + "\n" + T.usage_full

  klass.option :version,
    short: "-v",
    long: "--version",
    description:  T.version.description,
    boolean: true

  klass.option :help,
    short: "-h",
    long: "--help",
    description:   T.help.description,
    boolean: true

  # Special note:
  # config_path is pre-processed in startup.rb, and is shown here only
  # for the purpose of rendering help text.
  klass.option :config_path,
    short: "-c PATH",
    long: "--config PATH",
    description: T.default_config_location(ChefApply::Config.default_location),
    default: ChefApply::Config.default_location,
    proc: Proc.new { |path| ChefApply::Config.custom_location(path) }

  klass.option :identity_file,
    long: "--identity-file PATH",
    short: "-i PATH",
    description: T.identity_file,
    proc: (Proc.new do |paths|
      path = paths
      unless File.readable?(path)
        raise OptionValidationError.new("CHEFVAL001", nil, path)
      end

      path
    end)

  klass.option :ssl,
    long: "--[no-]ssl",
    description:  T.ssl.desc(ChefApply::Config.connection.winrm.ssl),
    boolean: true,
    default: ChefApply::Config.connection.winrm.ssl,
    proc: Proc.new { |val| ChefApply::Config.connection.winrm.ssl(val) }

  klass.option :ssl_verify,
    long: "--[no-]ssl-verify",
    description:  T.ssl.verify_desc(ChefApply::Config.connection.winrm.ssl_verify),
    boolean: true,
    default: ChefApply::Config.connection.winrm.ssl_verify,
    proc: Proc.new { |val| ChefApply::Config.connection.winrm.ssl_verify(val) }

  klass.option :protocol,
    long: "--protocol <PROTOCOL>",
    short: "-p",
    description: T.protocol_description(ChefApply::Config::SUPPORTED_PROTOCOLS.join(" "),
      ChefApply::Config.connection.default_protocol),
    default: ChefApply::Config.connection.default_protocol,
    proc: Proc.new { |val| ChefApply::Config.connection.default_protocol(val) }

  klass.option :user,
    long: "--user <USER>",
    description: T.user_description

  klass.option :password,
    long: "--password <PASSWORD>",
    description: T.password_description

  klass.option :cookbook_repo_paths,
    long: "--cookbook-repo-paths PATH",
    description: T.cookbook_repo_paths,
    default: ChefApply::Config.chef.cookbook_repo_paths,
    proc: (Proc.new do |paths|
      paths = paths.split(",")
      ChefApply::Config.chef.cookbook_repo_paths(paths)
      paths
    end)

  klass.option :install,
    long: "--[no-]install",
    default: true,
    boolean: true,
    description:  T.install_description

  klass.option :sudo,
    long: "--[no-]sudo",
    description: T.sudo.flag_description.sudo,
    boolean: true,
    default: true

  klass.option :sudo_command,
    long: "--sudo-command <COMMAND>",
    default: "sudo",
    description: T.sudo.flag_description.command

  klass.option :sudo_password,
    long: "--sudo-password <PASSWORD>",
    description: T.sudo.flag_description.password

  klass.option :sudo_options,
    long: "--sudo-options 'OPTIONS...'",
    description: T.sudo.flag_description.options
end

Instance Method Details

#parsed_optionsObject

I really don’t like that mixlib-cli refers to the parsed command line flags in a hash accessed via the ‘config` method. Thats just such an overloaded word.



142
143
144
# File 'lib/chef_apply/cli/options.rb', line 142

def parsed_options
  config
end