Skip to content

Commit 38aa679

Browse files
docs: update Other Technologies docs to be pulled from repo README's
Signed-off-by: Jonathan Norris <jonathan@taplytics.com>
1 parent 486f099 commit 38aa679

File tree

25 files changed

+705
-1034
lines changed

25 files changed

+705
-1034
lines changed
Lines changed: 240 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,240 @@
1+
---
2+
title: OpenFeature CLI
3+
sidebar_label: CLI
4+
sidebar_position: 1
5+
id: cli
6+
---
7+
8+
<p align="center" class="github-badges">
9+
<a href="https://github.com/orgs/open-feature/projects/17">
10+
<img alt="work-in-progress" src="https://img.shields.io/badge/status-WIP-yellow" />
11+
</a>
12+
<a href="https://cloud-native.slack.com/archives/C07DY4TUDK6">
13+
<img alt="Slack" src="https://img.shields.io/badge/slack-%40cncf%2Fopenfeature-brightgreen?style=flat&logo=slack" />
14+
</a>
15+
</p>
16+
17+
The OpenFeature CLI is a command-line tool designed to improve the developer experience when working with feature flags.
18+
It helps developers manage feature flags consistently across different environments and programming languages by providing powerful utilities for code generation, flag validation, and more.
19+
20+
The CLI bridges the gap between feature flag management systems and your application code by generating strongly typed flag accessors from a flag manifest. This approach provides:
21+
22+
- **Type Safety**: Generate strongly-typed flag accessors for your preferred language
23+
- **Developer Experience**: Reduce errors and improve IDE autocomplete support
24+
- **Language Support**: Generate code for TypeScript, JavaScript, React, Go, C#, and more
25+
26+
## Installation
27+
28+
### via curl
29+
30+
The OpenFeature CLI can be installed using a shell command.
31+
This method is suitable for most Unix-like operating systems.
32+
33+
```bash
34+
curl -fsSL https://openfeature.dev/scripts/install_cli.sh | sh
35+
```
36+
37+
### via Docker
38+
39+
The OpenFeature CLI is available as a Docker image in the [GitHub Container Registry](https://github.com/open-feature/cli/pkgs/container/cli).
40+
41+
You can run the CLI in a Docker container using the following command:
42+
43+
```bash
44+
docker run -it -v $(pwd):/local -w /local ghcr.io/open-feature/cli:latest
45+
```
46+
47+
### via Go
48+
49+
If you have `Go >= 1.23` installed, you can install the CLI using the following command:
50+
51+
```bash
52+
go install github.com/open-feature/cli/cmd/openfeature@latest
53+
```
54+
55+
### via pre-built binaries
56+
57+
Download the appropriate pre-built binary from the [releases page](https://github.com/open-feature/cli/releases).
58+
59+
## Quick Start
60+
61+
1. Create a flag manifest file in your project root:
62+
63+
```bash
64+
cat > flags.json << EOL
65+
{
66+
"$schema": "https://raw.githubusercontent.com/open-feature/cli/refs/heads/main/schema/v0/flag-manifest.json",
67+
"flags": {
68+
"enableMagicButton": {
69+
"flagType": "boolean",
70+
"defaultValue": false,
71+
"description": "Activates a special button that enhances user interaction with magical, intuitive functionalities."
72+
}
73+
}
74+
}
75+
EOL
76+
```
77+
78+
> [!NOTE]
79+
> This is for demonstration purposes only.
80+
> In a real-world scenario, you would typically want to fetch this file from a remote flag management service.
81+
> See [here](https://github.com/open-feature/cli/issues/3), more more details.
82+
83+
2. Generate code for your preferred language:
84+
85+
```bash
86+
openfeature generate react
87+
```
88+
89+
See [here](https://github.com/open-feature/cli/blob/docs-update-readme-for-website/docs/commands/openfeature_generate.md) for all available options.
90+
91+
3. View the generated code:
92+
93+
```bash
94+
cat openfeature.ts
95+
```
96+
97+
**Congratulations!**
98+
You have successfully generated your first strongly typed flag accessors.
99+
You can now use the generated code in your application to access the feature flags.
100+
This is just scratching the surface of what the OpenFeature CLI can do.
101+
For more advanced usage, read on!
102+
103+
## Commands
104+
105+
The OpenFeature CLI provides the following commands:
106+
107+
### `init`
108+
109+
Initialize a new flag manifest in your project.
110+
111+
```bash
112+
openfeature init
113+
```
114+
115+
This command creates a `flags.json` file in your current directory with the proper schema reference.
116+
You can customize the manifest path using configuration options.
117+
118+
See [here](https://github.com/open-feature/cli/blob/docs-update-readme-for-website/docs/commands/openfeature_init.md) for all available options.
119+
120+
### `generate`
121+
122+
Generate strongly typed flag accessors for your project.
123+
124+
```bash
125+
# List available languages
126+
openfeature generate
127+
128+
# Generate for a specific language
129+
openfeature generate typescript
130+
131+
# With custom output directory
132+
openfeature generate typescript --output ./src/flags
133+
```
134+
135+
**Supported Languages:**
136+
137+
| Language | Description |
138+
|----------|-------------|
139+
| `typescript` | TypeScript flag accessors |
140+
| `javascript` | JavaScript flag accessors |
141+
| `react` | React hooks for feature flags |
142+
| `go` | Go flag accessors |
143+
| `csharp` | C# flag accessors |
144+
| `java` | Java flag accessors |
145+
| `python` | Python flag accessors |
146+
| `nestjs` | NestJS flag accessors |
147+
| `nodejs` | Node.js flag accessors |
148+
149+
See [here](https://github.com/open-feature/cli/blob/docs-update-readme-for-website/docs/commands/openfeature_generate.md) for all available options.
150+
151+
### `version`
152+
153+
Print the version number of the OpenFeature CLI.
154+
155+
```bash
156+
openfeature version
157+
```
158+
159+
See [here](https://github.com/open-feature/cli/blob/docs-update-readme-for-website/docs/commands/openfeature_version.md) for all available options.
160+
161+
## Flag Manifest
162+
163+
The flag manifest is a JSON file that defines your feature flags and their properties.
164+
It serves as the source of truth for your feature flags and is used by the CLI to generate strongly typed accessors.
165+
The manifest file should be named `flags.json` and placed in the root of your project.
166+
167+
### Flag Manifest Structure
168+
169+
The flag manifest file should follow the [JSON schema](https://raw.githubusercontent.com/open-feature/cli/refs/heads/main/schema/v0/flag-manifest.json) with the following properties:
170+
171+
- `$schema` - The URL of the JSON schema for validation
172+
- `flags` - An object containing the feature flags
173+
- `flagKey` - A unique key for the flag
174+
- `description` - A description of what the flag does
175+
- `type` - The type of the flag (`boolean`, `string`, `number`, `object`)
176+
- `defaultValue` - The default value of the flag
177+
178+
### Example Flag Manifest
179+
180+
```json
181+
{
182+
"$schema": "https://raw.githubusercontent.com/open-feature/cli/refs/heads/main/schema/v0/flag-manifest.json",
183+
"flags": {
184+
"uniqueFlagKey": {
185+
"description": "Description of what this flag does",
186+
"type": "boolean|string|number|object",
187+
"defaultValue": "default-value",
188+
}
189+
}
190+
}
191+
```
192+
193+
## Configuration
194+
195+
The OpenFeature CLI uses an optional configuration file to override default settings and customize behavior.
196+
This file can be in JSON or YAML format and should be named either `.openfeature.json` or `.openfeature.yaml`.
197+
198+
### Configuration File Structure
199+
200+
```yaml
201+
# Example .openfeature.yaml
202+
manifest: "flags/manifest.json" # Overrides the default manifest path
203+
generate:
204+
output: "src/flags" # Overrides the default output directory
205+
# Any language-specific options can be specified here
206+
# For example, for React:
207+
react:
208+
output: "src/flags/react" # Overrides the default React output directory
209+
# For Go:
210+
go:
211+
package: "github.com/myorg/myrepo/flags" # Overrides the default Go package name
212+
output: "src/flags/go" # Overrides the default Go output directory
213+
```
214+
215+
### Configuration Priority
216+
217+
The CLI uses a layered approach to configuration, allowing you to override settings at different levels.
218+
The configuration is applied in the following order:
219+
220+
```mermaid
221+
flowchart LR
222+
default("Default Config")
223+
config("Config File")
224+
args("Command Line Args")
225+
default --> config
226+
config --> args
227+
```
228+
229+
## Get Involved
230+
231+
- **GitHub Repository**: [open-feature/cli](https://github.com/open-feature/cli)
232+
- **CNCF Slack**: Join the conversation in the [#openfeature](https://cloud-native.slack.com/archives/C0344AANLA1) and [#openfeature-cli](https://cloud-native.slack.com/archives/C07DY4TUDK6) channel
233+
- **Regular Meetings**: Attend our [community calls](https://zoom-lfx.platform.linuxfoundation.org/meetings/openfeature)
234+
- **GitHub Issues**: Report bugs or request features in our [issue tracker](https://github.com/open-feature/cli/issues)
235+
- **Social Media**:
236+
- Twitter: [@openfeature](https://twitter.com/openfeature)
237+
- LinkedIn: [OpenFeature](https://www.linkedin.com/company/openfeature/)
238+
239+
For more information, visit our [community page](https://openfeature.dev/community/).
240+

0 commit comments

Comments
 (0)