EivindArvesen / prm

A minimal project manager for the terminal.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Pass parameters to start script

liborw opened this issue · comments

It would be nice to be able to pass additional parameters to the start script.

I'm not sure I understand what you mean.

Could you describe a problem this would solve, and/or give me an example of using the solution in practice would look like?

Ok, I have a project where we are working with multiple robots. So, at start I would like to setup the shell to connect to particular robot, something like:

prm start project robot1

A work around would be to have several project with almost the same configuration but just some of the shell parameter set differently, i.e.:

prm start project-robot1

Currently the smallest unit in prm is a project. Although it is an interesting idea to look at a concept for project made out of projects
I can't think of an imediate abstraction to map it to.

That being said, what you ask can be done easily:

  1. In your start/end script you can call another script which will do the standard stuff and then have a few lines
    of the "robot specific" script.
  2. You can just parametrise your script and call it with specific parameters inside your start/end scripts.

Does this make scence ?

Regards!

@liborw : I see.

@IamBC : I discussed something semi-related in #14 (dynamic templating).
Basically, I suggested a loader-function that sources a custom user-script from a reserved path.
Ex: prm_load 'my_python_activation'

I think the functionality proposed in this issue sounds useful.
Startup-scripts could be sourced start.sh "${@:3}", in addition to setting a new variable $PRM_ACTIVE_PROJECT to avoid the mess of using arg $1 in user scripts, etc.

This would be useful for passing parameters in the way that @liborw originally suggested, but I think it's important to point out (both in this discussion, and eventually in the docs/readme) that its intended use is with not meta-projects or inherited projects – which presently have no built-in support, though the problems they solve can be solved manually, e.g. via prm copy.

In essence, supporting things like prm start project feature-or-environment (and changing between these) would increase complexity, for a modest return in functionality, which can be achieved more easily in other ways.

As for facilitating extensions and inheritance in projects, I think #14 would help.

Looks like this wasn't as easy as I thought yesterday.
The start.sh "${@:3}" method I proposed is not possible; all args are shared between all scripts involved, because of the sourcing situation.

As far as I can tell, the cleanest way to solve this is to set a pre-defined number of variables (e.g. 1; $PRM_SCRIPT_VARIABLE, or some such) for use in start- and stop-scripts.
Thoughts?

Damn. The easiest way to achieve this would of course be to use the args themselves.

@liborw : Just thought more about this. You could just use $3 (which would be the first argument after your project name) in your script.
If you think this works I'll mention it in the readme, possibly add it to the comments in the beginning of the start- and stop-scripts of newly created projects.

Surprised this didn't come up before;P

I'm closing this since I've documented how to pass additional parameters to the start script in the readme and in the comments in scripts of newly created projects.

Please re-open if there is still a problem.