Assaf Arkin wrote:
On Sun, Aug 31, 2008 at 1:02 AM, Ittay Dror <[EMAIL PROTECTED]> wrote:
This patch adds the ability to run buildr as 'buildr -p <project name>',
instead of 'cd' to the project's base directory. This is more comfortable
when building several projects and when using buildr as a tool from an ide
(since specifying an argument is easier than specifying a working dir)

A few suggestions:
[SNIP]
so do you want to continue the discussion in JIRA or here?
Specifically for this patch:
- You can already build a project without changing into its directory.
http://incubator.apache.org/buildr/projects.html#running_project_tasks
but i have to specify the task name instead of relying on the defaults. writing buildr <project name>:<task name> is confusing to my users. it is more confusing because there's help:projects and separate help:tasks. people don't think of projects as tasks.
- Command line options are used for controlling Buildr.application,
variables for controlling tasks.
i think this is controlling Buildr.application. it is telling buildr to run in the context of a certain project, treating projects as a special kind, not a task.
- Follow coding conventions.
where can i find the coding conventions?
- return projects if projects: when is projects ever nil?
right. it can't. will fix.
- local_projects expects a block.
only if a block is given ('elsif block')

Assaf



---
lib/buildr/core/application_cli.rb |    6 +++++-
lib/buildr/core/project.rb         |    4 ++++
2 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/lib/buildr/core/application_cli.rb
b/lib/buildr/core/application_cli.rb
index 3a19cf9..3f826e8 100644
--- a/lib/buildr/core/application_cli.rb
+++ b/lib/buildr/core/application_cli.rb
@@ -59,7 +59,9 @@ module Buildr
       ['--version',  '-v', GetoptLong::NO_ARGUMENT,
         'Display the program version.'],
       ['--environment', '-e', GetoptLong::REQUIRED_ARGUMENT,
-          'Environment name (e.g. development, test, production).']
+          'Environment name (e.g. development, test, production).'],
+        ['--project',  '-p', GetoptLong::REQUIRED_ARGUMENT,
+          'Project name, can be relative to current directory']
     ]

   def collect_tasks
@@ -99,6 +101,8 @@ module Buildr
       options.show_task_pattern = Regexp.new(value || '.')
     when '--nosearch', '--quiet', '--trace'
       super
+      when '--project'
+         options.project = value
     end
   end

diff --git a/lib/buildr/core/project.rb b/lib/buildr/core/project.rb
index 6a37751..d5c511a 100644
--- a/lib/buildr/core/project.rb
+++ b/lib/buildr/core/project.rb
@@ -336,6 +336,10 @@ module Buildr
     end

     def local_projects(dir = nil, &block) #:nodoc:
+        if dir.nil? and Buildr.application.options.project
+          projects = local_projects('.').map{|p|
project("#{p}:#{Buildr.application.options.project}")}
+          return projects if projects
+        end
       dir = File.expand_path(dir || Buildr.application.original_dir)
       projects = Project.projects.select { |project| project.base_dir ==
dir }
       if projects.empty? && dir != Dir.pwd && File.dirname(dir) != dir
--
1.6.0.36.g3814c

--
Ittay Dror <[EMAIL PROTECTED]>
Tikal <http://www.tikalk.com>
Tikal Project <http://tikal.sourceforge.net>




--
--
Ittay Dror <[EMAIL PROTECTED]>

Reply via email to