#!/usr/bin/env python

import time
from subprocess import call

def _cmd(cmd):
    call(cmd,shell=True)

def ros_env():
    _cmd("tmux new-session -d \'vim\'")
    _cmd("tmux split-window -v -p 30")
    _cmd("tmux split-window -h -p 25")
    _cmd("tmux new-window \'mutt\'")
    _cmd("tmux -2 attach-session -d")

def rails_env():
    _cmd("tmux new-session -d \'vim\'")
    _cmd("tmux split-window -v -p 30")
    _cmd("tmux split-window -h -p 20")
    _cmd("tmux new-window \'mutt\'")
    _cmd("tmux -2 attach-session -d")

def octave_env():
    _cmd("tmux new-session -d \'vim\'")
    _cmd("tmux new-window \'mutt\'")
    _cmd("tmux split-window -h -p 50 -d \'octave --no-gui\'")
    _cmd("tmux -2 attach-session -d")

env_builders = {"ros": ros_env,
                "rails": rails_env,
                "oct": octave_env}

default_env = "rails"

env = default_env
env_arg = str(raw_input('Specify the env type: [rails] '))

if env_arg!="":
    if env_arg in env_builders:
        print "\n---> Launching the [{}] env".format(env_arg)
        env = env_arg
    else:
        print "\n--->Unknown env type [{}]\n".format(env_arg)+ \
               "---> Available: ros|rails"
else:
    print "\n---> Falling back on default environment [{}]".format(env)

time.sleep(0.5)

env_builders[env]()
