Skip to content
 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

unleash-cli

CLI for interfacing with Unleash: https://www.getunleash.io/

Install

Homebrew:

brew install nunogois/brews/unleash

npm / yarn global install:

npm i -g @nunogois/unleash-cli
yarn global add @nunogois/unleash-cli

Or you can download the latest release instead.

Setup

Before using unleash, you should login into your Unleash instance:

unleash login

For scripts and CI, pass credentials explicitly. Use an admin API token for automation when one is available:

unleash login --url https://unleash.example.com --token "$UNLEASH_API_TOKEN"

Instances using Unleash's username/password login can create a local session:

unleash login --url https://unleash.example.com --username "$UNLEASH_USERNAME" --password "$UNLEASH_PASSWORD"

You can also copy .env.example to .env and set UNLEASH_URL, UNLEASH_USERNAME, and UNLEASH_PASSWORD (or UNLEASH_API_TOKEN). The CLI also accepts the existing lowercase username and password names. It loads .env automatically, so unleash login can run without exposing credentials in shell history. .env is ignored by Git.

The password is used only for the login request. The CLI stores the returned session cookie (or API token) in config.json with owner-only permissions, so keep that file private. Sessions eventually expire; run unleash login again if a command reports that the session is no longer authorized.

Profiles

Use separate environment files and local sessions for QA, staging, and production:

cp .env.example .env.qa
cp .env.example .env.stg
cp .env.example .env.prod

unleash login --profile qa
unleash login --profile stg
unleash login --profile prod

unleash list --profile qa
unleash toggle GOAPP-EXPRESS-USERS --profile prod

--profile qa loads .env.qa and stores the resulting session in config.qa.json. No --profile uses .env and config.json as before. To use one profile for an entire shell session, set UNLEASH_PROFILE before running the CLI:

export UNLEASH_PROFILE=qa
unleash list
unleash toggle MEMMOB-DEFAULTS

Read toggles

These commands do not change Unleash:

# List every toggle in the selected profile.
unleash list --profile qa

# Limit the list to one or more naming prefixes.
unleash list --profile qa --prefix MEMMOB- --prefix GOAPP-

# Show a feature's enabled state, variants, and activation strategies.
unleash toggle MEMMOB-DEFAULTS --profile qa

# Print a variant's formatted JSON payload.
unleash toggle MEMMOB-DEFAULTS --variant defaults --profile qa

# Print a strategy's parameters and constraints.
unleash toggle GOAPP-EXPRESS-USERS --strategy userWithId --profile qa

Write toggles

These commands change the selected Unleash profile. Confirm the profile before running them, especially for production.

# Enable or disable an entire feature.
unleash enable GOAPP-EXPRESS-USERS --profile qa
unleash disable GOAPP-EXPRESS-USERS --profile qa

# Edit a JSON variant payload interactively.
unleash edit-variant MEMMOB-DEFAULTS defaults --profile qa

# Edit a strategy's parameters and constraints interactively.
unleash edit-strategy GOAPP-EXPRESS-USERS userWithId --profile qa

unleash edit-variant opens a variant's JSON payload in your default macOS text editor; unleash edit-strategy uses the same flow. Save the document, return to the terminal, and continue. The CLI validates the JSON, reports when nothing changed, and asks for a final confirmation before updating Unleash. Set EDITOR, for example export EDITOR='code --wait', to use a specific editor.

Use unleash -h to see all the available commands.

About

CLI for interfacing with Unleash: https://www.getunleash.io/

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages