lib/hyde/cli/helpers.rb in hydeweb-0.1.1 vs lib/hyde/cli/helpers.rb in hydeweb-0.1.2

- old
+ new

@@ -1,8 +1,31 @@ class Hyde class CLI module Helpers + def show_help_for(task) + name = params.first + task = task(name) + pass "No such command. Try: #{executable} help" unless task + + help = task.help + if help + help.each { |line| err line } + err + else + err "Usage: #{executable} #{task.usage || name}" + err "#{task.description}." if task.description + end + end + + def tasks_for(category) + tasks.select { |name, t| t.category == category } + end + + def other_tasks + tasks.select { |name, t| t.category.nil? } + end + def say_info(str) say_status '*', str, 30 end def say_status(what, cmd, color=32) @@ -10,15 +33,23 @@ c0 = "\033[0;m" puts "#{c1}%10s#{c0} %s" % [ what, cmd ] end def no_project - "No project file here." + "Error: This is not a Hyde project.\n" + + "You may convert it into one by creating a config file:\n" + + " $ #{executable} create .\n\n" + + "You may also create an empty project in a new directory:\n" + + " $ #{executable} create NAME\n" end + def project? + !! @hydefile + end + def project @project ||= begin - pass no_project unless @hydefile + pass no_project unless project? Dir.chdir File.dirname(@hydefile) begin project = Hyde::Project.new pass no_project unless project.config_file?