Move project listing to app.

This commit is contained in:
Glenn Y. Rolland 2014-01-03 00:35:21 +01:00
parent 52731febd5
commit 4cb5238065
2 changed files with 17 additions and 18 deletions

View file

@ -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

View file

@ -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