achiurizo / consular

Terminal automation
http://rdoc.info/github/achiu/consular/master/file/README.md
MIT License
813 stars 46 forks source link

blocking support #14

Closed dpickett closed 13 years ago

dpickett commented 14 years ago

I have a number of tabs that are dependent on the completion of a set of commands in tab 1 (a git pull and a rake db:migrate, for example). It would be great if I could have the other tabs wait for the completion of every command in tab 1.

I'd be happy to build this out, but I wasn't sure if you had a design strategy in mind.

KieranP commented 14 years ago

Agreed! I need tab one to authenticate a disk image, which takes input. Then after that, I need two other tabs to open up, but only once authenticated. So it needs the ability to call tabs within the commands, and delay tabs from loading. e.g.

- tab1:
  - [run disk image auth]
  - tab2 && tab3
- tab2_delayed:
  - resque-start
- tab3_delayed:
  - script/server
KieranP commented 14 years ago

Any chance of this now that the Ruby syntax is available? Should make it easier to implement?

Here is how I see it working:

window {
  tab :background_server {
    run "script/bgrb"
    open(:app_server)
  }
  tab :app_server, :auto_open => false {
    run "script/server"
  }
}

In this case, app_server would not be run right away. background_server would start, complete, then start the app_server tab.

achiurizo commented 13 years ago

This sounds like a good idea for rake tasks and such. However my question is how will the tab know the command is competed? in some cases, say i have a 'script/server' running, that terminal will hang. I was thinking a possible solution could be something like:

run "rake db:migrate", :wait => 10.seconds

Any ideas or suggestions?

@dpickett your more than welcome to build it out. help is always appreciated =)

KieranP commented 13 years ago

If the tab hangs, then it's not an issue. Anything successful will return 0 status code.

So for a chain of commands, you can do:

cd .... && then_this && then_that

If anything fails, then it'll stop like it should.

So if you wanted to migrate then start the server, you'd use:

window {
  tab :rails_app {
    run "rake db:migrate"
    run "script/server"
  }
}

That would do something like:

rake db:migrate && script/server

Does that make sense?

achiurizo commented 13 years ago

hey KieranP, yes that does make sense, thanks =). I'll have to add the tab block feature, but i do have your mentioned chain feature here: 6fb856daa519af6a4b2a55f494f933b4ad7df93f

so you could do this: run 'who','whoami','ls' which would translate that to: "who && whoami && ls" if you don't want them to chain, you'll just declare a command per run as normal.