Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
2f2665d
add support for github retriever
DeamonDev Sep 23, 2025
812c65d
refactor evaluate struct
DeamonDev Sep 25, 2025
9bb98da
add gitlab retriever support
DeamonDev Sep 28, 2025
a89ab25
fix formatting
DeamonDev Sep 28, 2025
09d5f1e
add support for bitbucket retriever
DeamonDev Sep 28, 2025
448aa69
add support for s3 retriever
DeamonDev Sep 29, 2025
1c05e87
start adding support for http retriever
DeamonDev Sep 29, 2025
8d62a36
add test for http retriever
DeamonDev Sep 30, 2025
1163fa1
add check flag
DeamonDev Oct 1, 2025
15052c2
add test for evaluate cmd http retriever
DeamonDev Oct 1, 2025
86ffc80
add more tests
DeamonDev Oct 2, 2025
f551f0d
add more tests for s3 and bitbucket
DeamonDev Oct 2, 2025
6e54164
add support for gcs
DeamonDev Oct 4, 2025
2d97760
little refactor
DeamonDev Oct 4, 2025
fc3678b
add support for mongodb
DeamonDev Oct 4, 2025
fadeb12
add support for azure and postgres
DeamonDev Oct 5, 2025
8230bce
start writing docs
DeamonDev Oct 5, 2025
d09c14f
add readme
DeamonDev Oct 5, 2025
58acc14
add timeout in docs
DeamonDev Oct 6, 2025
e0fb0ca
link redis options issue
DeamonDev Oct 6, 2025
fcf358d
add todo comment
DeamonDev Oct 6, 2025
c462a7e
Merge branch 'main' into feature-add-support-for-all-retrievers-in-cli
thomaspoignant Oct 16, 2025
8e94cb1
little refactor
DeamonDev Oct 17, 2025
76f0a13
trailing space
DeamonDev Oct 17, 2025
51a412b
make lint happy
DeamonDev Oct 17, 2025
19032d8
Merge branch 'main' into feature-add-support-for-all-retrievers-in-cli
DeamonDev Oct 17, 2025
37303f9
correct readme for cli
DeamonDev Oct 18, 2025
eb47d9a
correct initialization of retrievers
DeamonDev Oct 18, 2025
a2e0d93
correct tests after adding init calls
DeamonDev Oct 18, 2025
451998d
Merge branch 'main' into feature-add-support-for-all-retrievers-in-cli
DeamonDev Oct 20, 2025
e92a641
Merge branch 'main' into feature-add-support-for-all-retrievers-in-cli
DeamonDev Oct 21, 2025
9b34545
Merge branch 'main' into feature-add-support-for-all-retrievers-in-cli
DeamonDev Oct 23, 2025
b88bdbe
Merge branch 'main' into feature-add-support-for-all-retrievers-in-cli
DeamonDev Oct 24, 2025
f650bcc
Merge branch 'main' into feature-add-support-for-all-retrievers-in-cli
DeamonDev Oct 26, 2025
79ae1ef
Merge branch 'main' into feature-add-support-for-all-retrievers-in-cli
DeamonDev Oct 27, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
160 changes: 157 additions & 3 deletions cmd/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,194 @@

The GO Feature Flag Command Line is a CLI tool to interact with GO Feature Flag in your terminal.
For now it supports the following commands:

- `evaluate` to evaluate feature flags directly in your terminal
- `lint` to validate a configuration file format.

## How to install the cli

### Install using Homebrew (mac and linux)

```shell
brew tap thomaspoignant/homebrew-tap
brew install go-feature-flag-cli
```

### Install using docker

```shell
docker pull gofeatureflag/go-feature-flag-cli
```
More information about the usage of the container in the [dockerhub page](https://hub.docker.com/r/gofeatureflag/go-feature-flag-cli).

More information about the usage of the container in
the [dockerhub page](https://hub.docker.com/r/gofeatureflag/go-feature-flag-cli).

# How to use the command line

**`go-feature-flag-cli`** is a command line tool.

## How to evaluate a flag

The evaluate command allows you to evaluate a feature flag or inspect the configuration of your retriever using
`--check-mode`

```shell
go-feature-flag-cli evaluate [OPTIONS]
```

### Key Flags

| Flag | Shorthand | Description | Default |
|----------------|-----------|---------------------------------------------------------------------------------------------------------------------------------|---------|
| `--kind` | k | Kind of configuration source. Determines where to read your flags from | file |
| `--config` | c | Path to the local flag configuration file (⚠️ deprecated, use `--path` instead) | "" |
| `--format` | f | Format of your input file (YAML, JSON or TOML) | yaml |
| `--flag` | | Name of the flag to evaluate | "" |
| `--timeout` | | Timeout in seconds to access your configuration file | 0 |
| `--ctx` | | Evaluation context as a json string | {} |
| `--check-mode` | | Check only mode - when set, the command will not perform any <br/>evaluation and returns the configuration of spanned retriever | false |

Supported values for `--kind` are:

- `file`
- `http`
- `github`
- `gitlab`
- `s3`
- `googleStorage`
- `configmap` (kubernetes)
- `mongodb`
- `bitbucket`
- `azureBlobStorage`
- `postgresql`

**Caution**: We do not support `redis` retriever as for now due
to: https://github.com/thomaspoignant/go-feature-flag/issues/4023.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want to add the serializable layer on this PR or do you prefer to open another pull request for this?


### Retriever specific flags

The aforementioned `--kind` parameter is used to determine the retriever to use. The semantic meaning of other flags
depends on that one, for
example `--path` parameter is used to specify local file when `--kind` being `file` but when `--kind` being `github` it
is used to specify
the path to the remote file.

#### File

| Flag | Description | Default |
|----------|-------------------------------------------|---------|
| `--path` | Path to the local flag configuration file | "" |
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have a default value to file to be similar to the old behavior as much as possible?


#### HTTP

| Flag | Description | Default |
|------------|---------------------------------------------------------------------|---------|
| `--url` | URL of the remote flag configuration file | "" |
| `--method` | HTTP method to access your configuration file on HTTP | GET |
| `--body` | Http body to access your configuration file on HTTP | "" |
| `--header` | Header to add to the request. Supported formats are `k:v` and `k=v` | "" |

#### GitHub

| Flag | Description | Default |
|---------------------|-------------------------------------------------------------------------------------------------------------------|---------|
| `--repository-slug` | Name of the repository | "" |
| `--branch` | Git branch name | "" |
| `--auth-token` | Authentication token to access your configuration file | "" |
| `--github-token` | Authentication token to access your configuration file on GitHub<br/> (⚠️ deprecated, use `--auth-token` instead) | "" |
| `--path` | Path to the remote flag configuration file inside github repository | "" |

#### GitLab

| Flag | Description | Default |
|---------------------|---------------------------------------------------------------------|---------|
| `--base-url` | Base URL of your configuration file on Gitlab | "" |
| `--repository-slug` | Name of the repository | "" |
| `--branch` | Git branch name | "" |
| `--path` | Path to the remote flag configuration file inside gitlab repository | "" |

#### BitBucket

| Flag | Description | Default |
|---------------------|------------------------------------------------------------------------|---------|
| `--base-url` | Base URL of your configuration file on BitBucket | "" |
| `--repository-slug` | Name of the repository | "" |
| `--branch` | Git branch name | "" |
| `--path` | Path to the remote flag configuration file inside bitbucket repository | "" |

#### S3

| Flag | Description | Default |
|------------|--------------------|---------|
| `--bucket` | Name of the bucket | "" |
| `--item` | Item of the bucket | "" |

#### Google Storage

| Flag | Description | Default |
|------------|----------------------|---------|
| `--bucket` | Name of the bucket | "" |
| `--object` | Object of the bucket | "" |

#### ConfigMap (Kubernetes)

| Flag | Description | Default |
|----------------|----------------------------|-----------|
| `--namespace` | Namespace of the ConfigMap | "default" |
| `--config-map` | Name of the ConfigMap | "" |
| `--key` | Key of the ConfigMap | "" |

#### MongoDB

| Flag | Description | Default |
|----------------|-----------------------------------------------------|---------|
| `--uri` | URI of your configuration file | "" |
| `--database` | Database name of your configuration file on mongodb | "" |
| `--collection` | Collection of your configuration file on mongodb | "" |

#### Azure Blob Storage

| Flag | Description | Default |
|------------------|-----------------------------|---------|
| `--account-name` | Name of the storage account | "" |
| `--account-key` | Key of the storage account | "" |
| `--container` | Name of the container | "" |
| `--object` | Name of the object blob | "" |

#### PostgreSQL

| Flag | Description | Default |
|------------|----------------------------------------------------|---------|
| `--uri` | URI of your configuration file | "" |
| `--table` | Table of your configuration file | "" |
| `--column` | Column mapping to add. Supported format is `c1:c2` | "" |

As mentioned above the `--config` flag is deprecated and we encourage you to use the `--path` flag instead. For example
the following command:

```shell
go-feature-flag-cli evaluate --config="<location_of_your_flag_configuration_file>" --flag="<name_of_your_flag_to_evaluate>" --ctx='<evaluation_ctx_as_json_string>'
```

may be replaced by:

```shell
go-feature-flag-cli evaluate --kind="file" --path="<location_of_your_flag_configuration_file>" --flag="<name_of_your_flag_to_evaluate>" --ctx='<evaluation_ctx_as_json_string>'
Comment on lines +169 to +179
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏 praise: ‏This is great to have an example here.

```

## How to lint a configuration file

```shell
go-feature-flag-cli lint <location_of_your_flag_configuration_file> --format="<yaml or json or toml>"
```

# License

View [license](https://github.com/thomaspoignant/go-feature-flag/blob/main/LICENSE) information for the software contained in this image.
View [license](https://github.com/thomaspoignant/go-feature-flag/blob/main/LICENSE) information for the software
contained in this image.

## How can I contribute?
This project is open for contribution, see the [contributor's guide](https://github.com/thomaspoignant/go-feature-flag/blob/main/CONTRIBUTING.md) for some helpful tips.

This project is open for contribution, see
the [contributor's guide](https://github.com/thomaspoignant/go-feature-flag/blob/main/CONTRIBUTING.md) for some helpful
tips.
6 changes: 3 additions & 3 deletions cmd/cli/evaluate/evaluate.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import (
ffclient "github.com/thomaspoignant/go-feature-flag"
"github.com/thomaspoignant/go-feature-flag/modules/core/model"
"github.com/thomaspoignant/go-feature-flag/modules/core/utils"
"github.com/thomaspoignant/go-feature-flag/retriever/fileretriever"
"github.com/thomaspoignant/go-feature-flag/retriever"
)

type evaluate struct {
config string
retriever retriever.Retriever
fileFormat string
flag string
evaluationCtx string
Expand All @@ -24,7 +24,7 @@ func (e evaluate) Evaluate() (map[string]model.RawVarResult, error) {
PollingInterval: 10 * time.Minute,
DisableNotifierOnInit: true,
Context: context.Background(),
Retriever: &fileretriever.Retriever{Path: e.config},
Retriever: e.retriever,
FileFormat: e.fileFormat,
}

Expand Down
Loading
Loading