$: << "./lib"
require 'shoes'

Shoes.app do
	def row(message)
		flow do
			flow :width => 0.5 do; para message, :align => "right"; end;
			@ret = edit_line '', :width => 0.5
		end
		@ret
	end


	stack do
		@project_name = row("Project Name")
		@author       = row("Author (That's you, yo!)")
		@version      = row("Version Name")
		
		para "Where is this mess? Browse for your entry point rb file. "+
			"This shymaker will guess the remaining questions based "+
			"on the path. Feel free to correct the shymaker if it makes bold "+
			"assumptions. ;)", :align => "center"
		
		button "Browse to the entry point" do
			browse = ask_open_file
			sep = browse['/'] || '\\'
			parts = browse.split(sep)
			@path.text = parts[0..-2].join(sep) + sep
			@entry_rel.text = parts[-1]
			@dest.text = parts[0..-2].join(sep) +'.shy'
		end

		@path      = row("Absolute Path to zip up")
		@entry_rel = row("Entry point, relative to zipped up path")
		@dest      = row("Absolute Path to shy archive you'd like to create")
		
		button "Make Shy" do  
		    @status.replace "Status: Making a shy, please wait.."
			begin
				s = Shy.new
				s.name = @project_name.text
				s.creator = @author.text
				s.version = @version.text
				s.launch = @entry_rel.text
				Shy.c(@dest.text, s, @path.text)
#			rescue
#				alert("Something apparently went screwy? Aborting shy compile.")
			end
			@status.replace "Status: Shy made! So.. you can totally make "+
				"another if you want."
		end
		
		@status = para "Status: Waiting for you to push the 'Make Shy' button",
			:align => "center"
	end
end