It is often required to release a feature for Snapcraft hidden behind flags to not inadvertently make use of them without tending to the consequences for its potential instability, the instability can be present in different ways:
- The feature itself is not stable or does not consider all the corner cases.
- The command line interface is subject to change.
- The command output is subject to change.
This document defines a common pattern to follow to enable features that must be disabled by default.
These are the guidelines to enable a feature through a feature flag:
- The feature flag toggle shall be present as a command line option and as an environment variable.
- The feature flag toggle shall always be present in the help.
- When the feature flag is toggled a warning shall be displayed.
In general features are enabled with options on the command line interface with
the following pattern --experimental-<feature>
and with an environment
variable SNAPCRAFT_EXPERIMENTAL_<FEATURE>
.
Given the feature feature, the syntax shall have the following pattern:
snapcraft --experimental-feaure
And through the environment variable:
SNAPCRAFT_EXPERIMENTAL_FEATURE=y snapcraft
If snapcraft-yaml
makes use of a feature that requires a feature flag and
error shall be presented with hints about enabling the experimental feature.
Given the feature feature enabled by use of the --feature
option, the
syntax shall have the following pattern:
snapcraft --feature --experimental-feature
And through the environment variable:
SNAPCRAFT_EXPERIMENTAL_FEATURE=y snapcraft --feature
When using --feature
without using the experimental flag, a command line
option error shall be presented.
To expose new output through a feature flag the syntax shall have the following pattern:
snapcraft --experimental-feature
And through the environment variable:
SNAPCRAFT_EXPERIMENTAL_FEATURE=y snapcraft
When the flag is not present, the stable output must be shown.