diff --git a/lib/kook/app.rb b/lib/kook/app.rb index eb52fc5..4b25f73 100644 --- a/lib/kook/app.rb +++ b/lib/kook/app.rb @@ -16,6 +16,22 @@ module Kook @current_project = nil end + def list_projects + projects_exist = false + + @projects.each do |project_name,project_data| + projects_exist = true + exist = File.exist? project_data.path + display_path = ( + project_data.path.clone + .gsub!(/#{ENV['HOME']}/,'~') + .send(exist ? :green : :red) + ) + puts "%- 24s %s" % [project_name, display_path] + end + STDERR.puts "No project found." if not projects_exist + end + def add_project project_name, project_path=nil raise ExistingProject if @projects.has_key? project_name @@ -51,12 +67,6 @@ module Kook end end - def each_project - @projects.each do |p,data| - yield p,data - end - end - def add_view project_name, view_name, view_path=nil Project.validate_name project_name View.validate_name view_name diff --git a/lib/kook/cli.rb b/lib/kook/cli.rb index 033c6ef..20ac538 100644 --- a/lib/kook/cli.rb +++ b/lib/kook/cli.rb @@ -52,18 +52,7 @@ module Kook desc "list", "List projects" def list before_filter options - projects_exist = false - @app.each_project do |project_name,project_data| - projects_exist = true - exist = File.exist? project_data.path - display_path = ( - project_data.path.clone - .gsub!(/#{ENV['HOME']}/,'~') - .send(exist ? :green : :red) - ) - puts "%- 24s %s" % [project_name, display_path] - end - STDERR.puts "Empty list : no project configured." if not projects_exist + @app.list_projects end option :path