joshnesbitt / project

A streamlined approach to working with multiple projects and tasks
http://rubygems.org/gems/project
MIT License
47 stars 6 forks source link

Add project subcommands #6

Open bomberstudios opened 14 years ago

bomberstudios commented 14 years ago

I have a somehow complex environment I need to run for my project (think Sphinx, delayed_job, etc...) and a nice addition for project would be to add project subcommands, so you can run stuff when starting a work session and stop stuff when finishing.

I.e, if I have this .project file:

:workflows:
  :default:
    :start:
      - mate %path
      - mysql_start # Start MySQL
      - cd %path && rake ts:start #start Sphinx
      - cd %path && rails server
    :stop:
      - mysql_stop # Stop MySQL
      - cd %path && rake ts:stop #stop Sphinx
:projects:
  :myproject:
    :path: /path/to/project
    :workflow: default

then running

$ project myproject start

would open TextMate, bring MySQL and Sphinx up, and start the Rails server, and

$ project myproject stop

would stop MySQL and Sphinx.

(The 'start' command would be default, so project myproject would be equivalent to project myproject start)

I may have a go at it, but I make no promises... : )

joshnesbitt commented 14 years ago

That's a really nice idea.

I'm wondering if this could help get around issue #5 by using something like dtach to control a commands background process (to explicitly stop/start daemons). For the sake of making it backwards compatible maybe project could assume that project name has the current yaml configuration but project name subcommand will try to look for the subcommand key within the workflow.

joshnesbitt commented 14 years ago

http://trollop.rubyforge.org/ will work nicely.