BundleWorks provides a use command to allow a particular environment to be loaded. As mentioned earlier, if an environment name is unique, that name is all that is needed to use an environment. Otherwise, the full path to the environment is necessary.
Executing the 'use' command with an environment name or path does the following:
All deployed bundles are checked for a 'load' Bundle hook (both inside the bundle's 'actions' directory and inside the deployed bundle's 'work/actions' directory). If a 'load' hook is found, this hook is executed, which typically sets variables in the current environment.
All deployed bundles are checked to see if they are executable. If a bundle can be executed, then an alias is created to execute commands on that bundle. For example, in the scenario presented earlier, an alias to the executable 'helloserver' bundle is created when an environment containing this bundle is loaded. If the environment is at /local/env/test, the alias is 'helloserver=bw "/local/env/test/helloserver"'. This means that executing 'helloserver start' is the same as executing 'bw "/local/env/test/helloserver" start'.
If any deployed bundles match the names of bundles that have already been loaded, BundleWorks will execute the 'unload' Bundle hook on the previously loaded bundle to undo any effects on the environment before loading the new bundle.
Note that the 'use' command cannot be used on a bundle directly. It can only be used with an environment.