Skip to content

BRJS Context Aware Commands Proposal

dchambers edited this page Dec 2, 2014 · 2 revisions

BRJS Global Install and 'Context aware' commands proposal

Currently to create an app, then create a blade within that app, then run the blade tests, you would run the following commands:

cd sdk
./brjs create-app my-app
./brjs create-blade my-app default b1
./brjs test ../apps/my-app/blades/b1/

If BRJS supported being used from the PATH (we need to verify if this is possible already) then something like the following would be possible:

cd apps
brjs create-app my-app
brjs create-blade my-app default b1
brjs test apps/my-app/blades/b1/

To further simplify this we should aim to remove the extra information passed to the commands so they can operate within the current directory, for example the following could be used to achieve the above:

cd apps
brjs create-app my-app
cd my-app
brjs create-blade b1
brjs test blades/b1

There are several options we have here. In the examples below the context is the current node (Aspect, BladeSet, BLade etc.) from where the command is being executed.

1. Do nothing, does it add that much value to remove the extra args?

We could do nothing and keep the current syntax where all args must always be provided. This is obviously the easiest option as far as work required goes.

2. Automatically guess the context based on the current directory and allow it to be overridden via a final argument for every command

We could guess the context based on the current working directory and if the context isn't correct the command being executed then throw an exception. The context directory could be optionally set by using a final argument for each command. For example the following set of commands would do identical things:

cd sdk
brjs create-app my-app
brjs create-blade b1 ../apps/my-app
brjs test ../apps/my-app/blades/b1
cd apps
brjs create-app my-app
cd my-app
brjs create-blade b1
brjs test ./blades/b1
3. Automatically guess the context based on the current directory so commands must be run from the right location

Similar to above we guess the context of the command based on the current working directory. Unlike the option above we do not allow the context to be set via a final argument and require the user to cd into the right directory for each command. e.g.

cd apps
brjs create-app my-app
cd my-app
brjs create-blade b1
brjs test ./blades/b1
Clone this wiki locally