Leaf Env

leaf env - manages leaf environment variables

leaf env [print] [PROFILE] [--activate-script FILE] [--deactivate-script FILE]

leaf env builtin

leaf env user [--set KEY=VALUE ...] [--unset KEY ...]

leaf env workspace [--set KEY=VALUE ...] [--unset KEY ...]

leaf env profile [PROFILE] [--set KEY[=VALUE] ...] [--unset KEY ...]

leaf env package PACKAGE

leaf env command sets and gets environment variables for:

  • user configuration
  • workspace configuration
  • profile configuration

leaf env can be further customized with SUB-COMMANDS.

Sub-Commands

Print

Prints the full environment (within the current context) and is the default command for leaf env This full environment is a concatenation of the following scopes:

  • builtin variables
  • user scope variables
  • workspace scope variables
  • profile scope variables
  • package scope variables, for each package contained in the specified/current profile

The command output is a shell script that can be directly evaluated to configure the environment.

The order listed explains the overriding workflow between different scopes. i.e.; A variable set in the profile scope will override the value set in the workspace scope.

Alternatively the --activate-script and/or --deactivate-script options can be used to generate script files, ready to be sourced in the current terminal to set/unset the environment for the current context (this is what is implicitly done by the leaf shell command).

The output shell script includes comments highlighting from which scope is coming every environment variable. These comments can be disabled by using the -q option.

Builtin

Displays the built-in LEAFXX variables:

  • LEAFVERSION: current leaf tool version
  • LEAFPLATFORMSYSTEM: current platform operating system (i.e.; Linux)
  • LEAFPLATFORMMACHINE: current platform machine architecture (i.e.; x8664 / i386)
  • LEAFPLATFORMRELEASE: current platform kernel version

User

Displays and configures variables in the global user scope. Variables in this scope are common to all workspaces. The variables configuration is stored in the main leaf configuration file (see leaf config).

The --set and --unset options can be used to configure the variables in this scope.

workspace

Displays and configures variables in the current workspace scope. Variables in this scope are specific to the current workspace and common to all profiles. The variables configuration is stored in the leaf-workspace.json workspace file (see leaf init).

In addition to the user defined variables, leaf will automatically set the LEAFWORKSPACE variable to the current workspace location.

The --set and --unset options can be used to configure the variables in this scope.

profile

Displays and configures variables in the current profile scope. Variables in this scope are specific to the specified/current profile. The variables configuration are stored in leaf-workspace.json (see leaf init).

In addition to the user defined variables, leaf will automatically set the LEAFPROFILE variable to the current profile name.

The --set and --unset options can be used to configure the variables in this scope.

package

This command displays the environment provided by the package with PACKAGE identifier (see leaf help manifest).

Options

PROFILE

Profile name to work with, instead of working with current profile

PACKAGE

Installed package identifier from which to display the environment. See leaf help package for more details on package identifiers syntax.

--activate-script FILE

Generate a FILE shell script containing instructions to set the environment for the selected scope.

--deactivate-script FILE

Generate a FILE shell script containing instructions to unset the environment for the selected scope.

--set KEY[=VALUE]

Set the KEY variable to the specified VALUE in the selected scope.

--unset KEY

Unset the KEY variable in the selected scope.

Examples

Dump environment for current context:

leaf env

Load environment in current context:

eval $(leaf env print -q)

Display built-in environment:

leaf env builtin

Display user environment:

leaf env user

Add variable to user environment:

leaf env user --set MYVAR=1

Remove variable from user environment:

leaf env user --unset MYVAR

Display workspace environment:

leaf env workspace

Display profile environment:

leaf env profile

Display package environment:

leaf env package MYPACKAGE1.0