@@ -30,39 +30,23 @@ config = {
3030}
3131opts = OptionParser . new do |opts |
3232 opts . banner = "Usage: #{ $0} [-d DIR|-r FILE] (options)"
33- opts . on ( "-c CONFIG" , "--config CONFIG" , "The Chef Config file to use" ) do |c |
34- config [ :config_file ] = c
35- end
36- opts . on ( "-u USER" , "--user USER" , "User to change uid to before daemonizing" ) do |u |
37- config [ :user ] = u
38- end
39- opts . on ( "-g GROUP" , "--group GROUP" , "Group to change gid to before daemonizing" ) do |g |
40- config [ :group ] = g
41- end
42- opts . on ( "-d" , "--daemonize" , "Daemonize the process" ) do |d |
43- config [ :daemonize ] = true
44- end
45- opts . on ( "-i SECONDS" , "--interval SECONDS" , "Run chef-client peridoically, in seconds" ) do |i |
46- config [ :interval ] = i
47- end
48- opts . on ( "-j JSON_ATTRIBS" , "--json-attributes JSON_ATTRIBS" , "Load attributes from a JSON file" ) do |j |
49- config [ :json_attribs ] = j
50- end
51- opts . on ( "-N NODE_NAME" , "--node-name NODE_NAME" , "The node name for this client" ) do |n |
52- config [ :node_name ] = n
53- end
54- opts . on ( "-s SECONDS" , "--splay SECONDS" , "The splay time for running at intervals, in seconds" ) do |s |
55- config [ :splay ] = s
56- end
57- opts . on ( "-l LEVEL" , "--loglevel LEVEL" , "Set the log level (debug, info, warn, error, fatal)" ) do |l |
58- config [ :log_level ] = l . to_sym
59- end
60- opts . on ( "-L LOGLOCATION" , "--logfile LOGLOCATION" , "Set the log file location, defaults to STDOUT - recommended for daemonizing" ) do |lf |
61- config [ :log_location ] = lf
62- end
63- opts . on ( "-t TOKEN" , "--token TOKEN" , "Set the openid validation token" ) do |t |
64- config [ :validation_token ] = t
33+ {
34+ :config_file => { :short => "-c CONFIG" , :long => "--config CONFIG" , :description => "The Chef Config file to use" , :proc => nil } ,
35+ :user => { :short => "-u USER" , :long => "--user USER" , :description => "User to change uid to before daemonizing" , :proc => nil } ,
36+ :group => { :short => "-g GROUP" , :long => "--group GROUP" , :description => "Group to change gid to before daemonizing" , :proc => nil } ,
37+ :daemonize => { :short => "-d" , :long => "--daemonize" , :description => "Daemonize the process" , :proc => { |p | true } } ,
38+ :interval => { :short => "-i SECONDS" , :long => "--interval SECONDS" , :description => "Run chef-client periodically, in seconds" , :proc => nil } ,
39+ :json_attribs => { :short => "-j JSON_ATTRIBS" , :long => "--json-attributes JSON_ATTRIBS" , :description => "Load attributes from a JSON file" , :proc => nil } ,
40+ :node_name => { :short => "-N NODE_NAME" , :long => "--node-name NODE_NAME" , :description => "The node name for this client" , :proc => nil } ,
41+ :splay => { :short => "-s SECONDS" , :long => "--splay SECONDS" , :description => "The splay time for running at intervals, in seconds" , :proc => nil } ,
42+ :log_level => { :short => "-l LEVEL" , :long => "--loglevel LEVEL" , :description => "Set the log level (debug, info, warn, error, fatal)" , :proc => { |p | p . to_sym } } ,
43+ :log_location => { :short => "-L LOGLOCATION" , :long => "--logfile LOGLOCATION" , :description => "Set the log file location, defaults to STDOUT - recommended for daemonizing" , :proc => nil } ,
44+ :validation_token => { :short => "-t TOKEN" , :long => "--token TOKEN" , :description => "Set the openid validation token" , :proc => nil } , }
45+
46+ opts . on ( val [ :short ] , val [ :long ] , val [ :description ] ) do |c |
47+ config [ key ] = ( val [ :proc ] && val [ :proc ] . call ) || c
6548 end
49+
6650 opts . on_tail ( "-h" , "--help" , "Show this message" ) do
6751 puts opts
6852 exit 0
0 commit comments