mottosso / be

minimal directory and environment management system for collaborative creative projects
GNU Lesser General Public License v2.1
47 stars 4 forks source link

enter/exit #21

Open mottosso opened 9 years ago

mottosso commented 9 years ago

goal

Provide for arbitrary scripts to be executed upon entering an exiting a topic.

$ be in myproject hero modeling
Entering "myproject"..
$ exit
Exiting "myproject"..

implementation

At the moment, the script: portion of be.yaml does exactly this for enter, but there is no exit. Another question is whether to run the given commands via the command-line, or Python. The benefit of command-line is full integration with the newly entered environment, whereas Python would effectively run in the parent process that first launches the subshell and therefore not have access to the same environment.

However the shell language will vary across OSs, meaning be.yaml would not be fully cross-platform, which may make things tricky in multi-platform productions.

enter:
- echo Entering project..

exit:
- echo Exiting project..

scope

The second question to consider is where execution is to take place.

  1. If shell, run in the entered shell
  2. If shell, run in a separate shell, before entering (and after when exiting)
  3. If Python, run in the parent process of subshell
  4. If Python, run in a separate process before entering (and after when exiting)

One option is to allow for each.

before_enter:
- print "About to enter.."
enter:
- print "Entering.."
enter_after:
- print "Entered"

specificity

Due to the many possibilities of how and when and which language, the initial version should probably require a high level of specificity that will eventually phase off into generic terms as their usage levels out and a commonality found.

before_enter_python:
- print "About to enter.."
after_exit_python:
- print "Just exited.."