bin/sprout in sprout-0.5.15 vs bin/sprout in sprout-0.5.19
- old
+ new
@@ -15,19 +15,16 @@
include PatternPark
OPTIONS = {
:locations => [],
:project_name => nil,
- :found_project_name => nil,
:sprout_name => nil,
:update => false,
:update => false,
:clean => false
}
-MANDATORY_OPTIONS = %w( sprout_name )
-
parser = OptionParser.new do |opts|
opts.banner = <<BANNER
Sprouts is an open-source, cross-platform project generation and configuration tool
If you would like to edit or remove installed sprout contents or definitions,
simply navigate to the following location:
@@ -38,10 +35,15 @@
Options are:
BANNER
opts.separator ""
opts.on("-s", "--sprout=NAME", String,
+ "[DEPRECATED] The name of the sprout to create (e.g., as2 as3, haxe, or mxml)"
+ ) do |name|
+ OPTIONS[:sprout_name] = name
+ end
+ opts.on("-n", "--name=NAME", String,
"The name of the sprout to create (e.g., as2 as3, haxe, or mxml)"
) do |name|
OPTIONS[:sprout_name] = name
end
opts.on("-l", "--locations=URL[,URL2,URL3]", String,
@@ -61,45 +63,21 @@
end
opts.on("-h", "--help",
"Show this help message.") { puts opts; exit }
opts.parse!(ARGV)
- OPTIONS[:project_name] = ARGV.pop
-
- if(OPTIONS[:sprout_name].nil?)
- puts "\n[ERROR] You MUST provide a sprout name.\n\n"
+ if(OPTIONS[:sprout_name].nil? && OPTIONS[:update])
+ OPTIONS[:sprout_name] = ARGV.pop
+ else
+ OPTIONS[:project_name] = ARGV.pop
end
-
- if(OPTIONS[:sprout_name] && !OPTIONS[:project_name])
- dir = Sprout.project_path
- begin
- rakefile = Sprout.rakefile
- if(!rakefile.nil? && File.exists?(rakefile))
- require rakefile
- name = ProjectModel.instance.project_name
- end
- rescue LoadError
- name = File.basename(File.dirname(dir))
- end
- puts "\n[WARNING] No project name specified, Do you want to use '#{name}' as the project name and install the #{OPTIONS[:sprout_name]} sprout into #{dir}? [Yn]\n\n"
- answer = $stdin.gets.chomp
- if(answer.downcase != "y" && answer != "")
- puts opts; exit
- end
- OPTIONS[:found_project_name] = name
- end
-
- if MANDATORY_OPTIONS && MANDATORY_OPTIONS.find { |option| OPTIONS[option.to_sym].nil? }
- puts opts; puts ''; exit
- end
end
#############################################
sprout_name = OPTIONS[:sprout_name]
project_name = OPTIONS[:project_name]
-found_project_name = OPTIONS[:found_project_name]
locations = OPTIONS[:locations]
update = OPTIONS[:update]
clean = OPTIONS[:clean]
#############################################
@@ -107,22 +85,69 @@
# Add the provided locations to the sprout search path
if(locations.size > 0)
Sprout.insert_locations(OPTIONS[:locations])
end
+if(sprout_name.nil?)
+ puts "\n[ERROR] You MUST provide a sprout name, this is usually done with the -s [NAME] commandline option. Please enter a sprout name now:\n"
+ sprout_name = gets
+end
+
if(update)
- Sprout.update = true
msg = <<EOF
[WARNING] Are you sure you want to clobber all local sprout definitions referenced by "#{sprout_name}"? [Yn]
EOF
puts msg
response = gets.chomp!
- if(response != '' && response.downcase != 'y')
+ if(response == '' || response.downcase == 'y')
+ Sprout.update = true
+ else
+ Log.puts("[ERROR] Sprout execution terminated, please try again.")
exit
end
end
+if(sprout_name && !project_name)
+ dir = Sprout.project_path
+
+ begin
+ rakefile = Sprout.rakefile
+ if(!rakefile.nil? && File.exists?(rakefile))
+ require rakefile
+ name = ProjectModel.instance.project_name
+ puts 'rakefile: ' + rakefile
+ else
+ raise LoadError.new('rakefile was not found')
+ end
+ rescue LoadError
+ name = File.basename(dir).capitalize
+ end
+
+ puts "\n[WARNING] No project name specified, please choose from the following:"
+ puts "(1) Enter Name: Let me enter a project name and execute from #{dir}"
+ puts "(2) No Project: I'm just updating some sprout definitions"
+ puts "(3) End Process: OOPs, I'll start over..."
+ if(name != nil && name != '')
+ puts "(4) Use Inferred Name: '#{name}' and load '#{sprout_name}' into #{dir}"
+ end
+
+ answer = $stdin.gets.chomp
+
+ case answer
+ when "1" :
+ puts "Enter a project name now:"
+ project_name = gets.chomp!
+ when "2" :
+ when "4" :
+ project_name = name
+ else
+ Log.puts("[ERROR] Sprout execution terminated, please try again.")
+ exit
+ end
+
+end
+
# Create a new named Project
if(sprout_name && project_name)
path = File.join(Sprout.project_path, project_name)
Sprout.project_path = path
if(File.exists?(path))
@@ -150,17 +175,10 @@
TemplateResolver.instance.replace_all = true
sprout = Sprout.load(sprout_name)
sprout.execute
end
-if(sprout_name && !project_name)
- sprout = Sprout.load(sprout_name)
- sprout.execute
-end
-
-# Resolve the sprout within the current project
-if(found_project_name && update && sprout_name)
- Sprout.project_name = found_project_name
+if(sprout_name && update && !project_name)
sprout = Sprout.load(sprout_name)
sprout.execute
end
Log.flush