Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
polish up a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
danielsdeleo committed Nov 24, 2009
1 parent f1a326d commit dc88f0d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 26 deletions.
16 changes: 2 additions & 14 deletions chef/lib/chef/shef.rb
Original file line number Diff line number Diff line change
Expand Up @@ -179,25 +179,12 @@ class Options
:description => "Load attributes from a JSON file or URL",
:proc => nil

# not supported right now
# option :node_name,
# :short => "-N NODE_NAME",
# :long => "--node-name NODE_NAME",
# :description => "The node name for this client",
# :proc => nil

option :chef_server_url,
:short => "-S CHEFSERVERURL",
:long => "--server CHEFSERVERURL",
:description => "The chef server URL",
:proc => nil

option :validation_token,
:short => "-t TOKEN",
:long => "--token TOKEN",
:description => "Set the openid validation token",
:proc => nil

option :version,
:short => "-v",
:long => "--version",
Expand All @@ -213,7 +200,8 @@ def self.setup!
def parse_opts
parse_options
config[:config_file] = config_file_for_shef_mode
puts "attempting to load config file from #{config[:config_file]}"
config_msg = config[:config_file] || "none (standalone shef session)"
puts "loading configuration: #{config_msg}"
Chef::Config.from_file(config[:config_file]) if !config[:config_file].nil? && File.exists?(config[:config_file]) && File.readable?(config[:config_file])
Chef::Config.merge!(config)
end
Expand Down
33 changes: 21 additions & 12 deletions chef/lib/chef/shef/shef_session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,24 +69,33 @@ def rebuild_collection
private

def loading
loading = true
dot_printer = Thread.new do
print "Loading"
while loading
show_loading_progress
begin
yield
rescue => e
loading_complete(false)
raise e
else
loading_complete(true)
end
end

def show_loading_progress
print "Loading"
@loading = true
@dot_printer = Thread.new do
while @loading
print "."
sleep 0.5
end
print "done.\n\n"
end
begin
yield
ensure
loading = false
dot_printer && dot_printer.join
end
end

def loading_complete
def loading_complete(success)
@loading = false
@dot_printer.join
msg = success ? "done.\n\n" : "epic fail!\n\n"
print msg
end

def shorten_node_inspect
Expand Down

0 comments on commit dc88f0d

Please sign in to comment.