INPUT_FILE = "RunningShoes.dat"

class RunCommands

    private
    @@runCommands = nil
    @@hidden = nil
    
    public
    def RunCommands.refresh
        @@runCommands = {}
        @@hidden = {}
        File.foreach(INPUT_FILE) { |line|
            if line !~ /^#/
                key, value = line.split(/=/, 2) 
                value.sub!(/%([a-zA-Z0-9]*)%/, ENV[$+]) if value =~ /%([a-zA-Z0-9]*)%/
                @@runCommands[key] = value.strip if key !~ /^::/
                @@hidden[key.sub(/^::/, '')] = value.strip if key =~ /^::/
            end
        }
    end
    
    public
    def RunCommands.runCommand(aString)
        getSet[aString]
    end
    
    public
    def RunCommands.getSet
        refresh if @@runCommands.nil?
        @@runCommands
    end
    
    public
    def RunCommands.getHidden
        refresh if @@runCommands.nil?
        @@hidden
    end
    
end

Shoes.app(:title => "Running Shoes", :width => 640, :height => 500) do

  	@grey = rgb(80, 80, 80)

  	background gradient(black, @grey)
  
    stack do
    	para("Click on the Windows Command to Run", :stroke => white)
    	
    	RunCommands.getSet.keys.sort.each do |item|
 			caption(link(item, :stroke => yellow, :font => "12px", :underline => "none").click { 
 				runCommand = RunCommands.runCommand item
 				system("start \"#{item}\" #{runCommand}")
 			})
 		end
	end

end