Skip to content

Commit 38f3fa0

Browse files
author
jtimberman
committed
Add --version to chef-solr, fixes CHEF-1018
1 parent 4661728 commit 38f3fa0

2 files changed

Lines changed: 22 additions & 10 deletions

File tree

chef-solr/lib/chef/solr.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@
3434

3535
class Chef
3636
class Solr
37+
38+
VERSION = "0.8.6"
39+
3740
include Chef::Mixin::XMLEscape
3841

3942
attr_accessor :solr_url, :http

chef-solr/lib/chef/solr/application/solr.rb

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
# Licensed under the Apache License, Version 2.0 (the "License");
77
# you may not use this file except in compliance with the License.
88
# You may obtain a copy of the License at
9-
#
9+
#
1010
# http://www.apache.org/licenses/LICENSE-2.0
11-
#
11+
#
1212
# Unless required by applicable law or agreed to in writing, software
1313
# distributed under the License is distributed on an "AS IS" BASIS,
1414
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -21,19 +21,20 @@
2121
require 'chef/application'
2222
require 'chef/daemon'
2323
require 'chef/client'
24+
require 'chef/solr'
2425

2526
class Chef
2627
class Solr
2728
class Application
2829
class Solr < Chef::Application
29-
30-
option :config_file,
30+
31+
option :config_file,
3132
:short => "-c CONFIG",
3233
:long => "--config CONFIG",
3334
:default => "/etc/chef/solr.rb",
3435
:description => "The configuration file to use"
3536

36-
option :log_level,
37+
option :log_level,
3738
:short => "-l LEVEL",
3839
:long => "--log_level LEVEL",
3940
:description => "Set the log level (debug, info, warn, error, fatal)",
@@ -95,11 +96,19 @@ class Solr < Chef::Application
9596
option :solr_java_opts,
9697
:short => "-j OPTS",
9798
:long => "--java-opts OPTS",
98-
:description => "Raw options passed to Java"
99+
:description => "Raw options passed to Java"
100+
101+
option :version,
102+
:short => "-v",
103+
:long => "--version",
104+
:description => "Show chef-solr version",
105+
:boolean => true,
106+
:proc => lambda {|v| puts "chef-solr: #{Chef::Solr::VERSION}"},
107+
:exit => 0
99108

100109
def initialize
101110
super
102-
Chef::Log.level = Chef::Config[:log_level]
111+
Chef::Log.level = Chef::Config[:log_level]
103112
end
104113

105114
def setup_application
@@ -113,7 +122,7 @@ def setup_application
113122

114123
# Create the Jetty container
115124
unless File.directory?(Chef::Config[:solr_jetty_path])
116-
Chef::Log.warn("Initializing the Jetty container")
125+
Chef::Log.warn("Initializing the Jetty container")
117126
solr_jetty_dir = Chef::Resource::Directory.new(Chef::Config[:solr_jetty_path], nil, c.node)
118127
solr_jetty_dir.recursive(true)
119128
solr_jetty_dir.run_action(:create)
@@ -125,7 +134,7 @@ def setup_application
125134

126135
# Create the solr home
127136
unless File.directory?(Chef::Config[:solr_home_path])
128-
Chef::Log.warn("Initializing Solr home directory")
137+
Chef::Log.warn("Initializing Solr home directory")
129138
solr_home_dir = Chef::Resource::Directory.new(Chef::Config[:solr_home_path], nil, c.node)
130139
solr_home_dir.recursive(true)
131140
solr_home_dir.run_action(:create)
@@ -135,7 +144,7 @@ def setup_application
135144
solr_jetty_untar.run_action(:run)
136145
end
137146

138-
# Create the solr data path
147+
# Create the solr data path
139148
unless File.directory?(Chef::Config[:solr_data_path])
140149
Chef::Log.warn("Initializing Solr data directory")
141150
solr_data_dir = Chef::Resource::Directory.new(Chef::Config[:solr_data_path], nil, c.node)

0 commit comments

Comments
 (0)