Move project listing to app.
This commit is contained in:
parent
52731febd5
commit
4cb5238065
2 changed files with 17 additions and 18 deletions
|
@ -16,6 +16,22 @@ module Kook
|
||||||
@current_project = nil
|
@current_project = nil
|
||||||
end
|
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
|
def add_project project_name, project_path=nil
|
||||||
raise ExistingProject if @projects.has_key? project_name
|
raise ExistingProject if @projects.has_key? project_name
|
||||||
|
|
||||||
|
@ -51,12 +67,6 @@ module Kook
|
||||||
end
|
end
|
||||||
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
|
def add_view project_name, view_name, view_path=nil
|
||||||
Project.validate_name project_name
|
Project.validate_name project_name
|
||||||
View.validate_name view_name
|
View.validate_name view_name
|
||||||
|
|
|
@ -52,18 +52,7 @@ module Kook
|
||||||
desc "list", "List projects"
|
desc "list", "List projects"
|
||||||
def list
|
def list
|
||||||
before_filter options
|
before_filter options
|
||||||
projects_exist = false
|
@app.list_projects
|
||||||
@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
|
|
||||||
end
|
end
|
||||||
|
|
||||||
option :path
|
option :path
|
||||||
|
|
Loading…
Reference in a new issue