The feature CLI is a command‑line client for interacting with the Feature service.
It lets you manage feature flags (key/value pairs) exposed by the service.
From the cli directory:
cd cli
go build -o featureThis produces a feature binary.
feature [global flags] <command> [command arguments]These flags are defined on the root command in main.go and apply to all sub‑commands.
- Env var:
LOG_FORMAT - Default:
text - Allowed values:
text,json - Description: Log output format.
Examples:
feature --log-format text getall
feature --log-format json getall- Env var:
LOG_LEVEL - Default:
info - Allowed values:
debug,info,warn,error - Description: Minimum log level emitted by the CLI.
Examples:
feature --log-level debug getall
feature --log-level error get my-key- Env var:
ENDPOINT - Default:
localhost:8000 - Required: yes
- Description: Address of the Feature service endpoint.
Examples:
feature --endpoint localhost:8000 getall
ENDPOINT=localhost:8000 feature get my-keyPrints the Feature service name and version (using meta.Service and meta.Version).
feature --endpoint localhost:8000 versionStreams and prints all features as key: value pairs, one per line.
feature --endpoint localhost:8000 getallOutput example:
feature-a: enabled
feature-b: disabled
Gets a single feature by key.
feature --endpoint localhost:8000 get <key>- Arguments:
key(string) – feature key to retrieve.
On success, prints the feature name followed by a newline.
Example:
feature --endpoint localhost:8000 get my-featureSets or updates a feature key/value pair.
feature --endpoint localhost:8000 set <key> <value>- Arguments:
key(string) – feature key to set.value(string) – value to associate with the key.
Example:
feature --endpoint localhost:8000 set my-feature enabledDeletes a feature by key.
feature --endpoint localhost:8000 delete <key>- Arguments:
key(string) – feature key to delete.
Example:
feature --endpoint localhost:8000 delete my-featurePre‑sets (initializes) a feature key/value pair.
feature --endpoint localhost:8000 preset <key> <value>- Arguments:
key(string) – feature key to pre‑set.value(string) – value to associate with the key.
Example:
feature --endpoint localhost:8000 preset my-feature enabled# Get all features from a local service
feature --endpoint localhost:8000 getall
# Get a single feature
feature --endpoint localhost:8000 get my-feature
# Set a feature flag
feature --endpoint localhost:8000 set my-feature enabled
# Pre-set a feature
feature --endpoint localhost:8000 preset my-feature enabled
# Delete a feature
feature --endpoint localhost:8000 delete my-feature
# Use structured JSON logging at debug level
feature --endpoint localhost:8000 \
--log-format json \
--log-level debug \
getall