Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 6 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,10 @@
"extends": [
"oclif",
"oclif-typescript"
]
],
"rules": {
"no-prototype-builtins": 0,
"camelcase": 0,
"unicorn/filename-case": 0
}
}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ node_modules
oclif.manifest.json
.idea
flagsmith.json
FlagsmithTypes.ts
tsconfig.tsbuildinfo
Binary file added 1 - Adding a remote config.mov
Binary file not shown.
Binary file added 2 - Creating a new flag.mov
Binary file not shown.
Binary file added 3 - Dry run removing flag.mov
Binary file not shown.
78 changes: 60 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ $ npm install -g flagsmith-cli
$ flagsmith COMMAND
running command...
$ flagsmith (--version)
flagsmith-cli/0.1.2 darwin-arm64 node-v18.13.0
flagsmith-cli/0.3.0 darwin-arm64 node-v18.20.4
$ flagsmith --help [COMMAND]
USAGE
$ flagsmith COMMAND
Expand All @@ -62,38 +62,70 @@ USAGE
<!-- usagestop -->
# Commands
<!-- commands -->
* [`flagsmith generate-types PROJECT`](#flagsmith-generate-types-project)
* [`flagsmith get [ENVIRONMENT]`](#flagsmith-get-environment)
* [`flagsmith help [COMMANDS]`](#flagsmith-help-commands)

## `flagsmith generate-types PROJECT`

Fetch Flagsmith feature flags as JSON. By default pipes to stdout, allowing use with other tools; or write to a file with -o.

```
USAGE
$ flagsmith generate-types PROJECT [-a <value>] [-o <value>] [-e <value>] [-p]

ARGUMENTS
PROJECT Flagsmith project ID

FLAGS
-a, --api=<value> [default: https://api.flagsmith.com] The API endpoint (if self-hosted)
-e, --exclude=<value> Comma-separated list of feature names to exclude
-o, --output=<value> Write the fetched JSON to a file instead of stdout
-p, --parseObjects (experimental) Include full object values when fetching features

DESCRIPTION
Fetch Flagsmith feature flags as JSON. By default pipes to stdout, allowing use with other tools; or write to a file
with -o.

EXAMPLES
export FLAGSMITH_API_KEY=YOUR_KEY flagsmith generate-types PROJECT_ID | npx quicktype \
--src-lang json \
--lang typescript \
--just-types \
--explicit-unions \
--acronym-style camel \
--top-level FlagsmithTypes \
-o FlagsmithTypes.ts

export FLAGSMITH_API_KEY=YOUR_KEY flagsmith generate-types PROJECT_ID -o features.json
```

_See code: [src/commands/generate-types/index.ts](https://github.com/Flagsmith/flagsmith-cli/blob/v0.3.0/src/commands/generate-types/index.ts)_

## `flagsmith get [ENVIRONMENT]`

Retrieve flagsmith features from the Flagsmith API and output them to a file.

```
USAGE
$ flagsmith get [ENVIRONMENT] [-o <value>] [-a <value>] [-t
<value> -i <value>] [-p] [-e flags|environment]
$ flagsmith get [ENVIRONMENT] [-o <value>] [-a <value>] [-t <trait_key>=<trait_value>... -i <value>]
[-p] [-e flags|environment]

ARGUMENTS
ENVIRONMENT The flagsmith environment key to use, defaults to the environment
variable FLAGSMITH_ENVIRONMENT
ENVIRONMENT The flagsmith environment key to use, defaults to the environment variable FLAGSMITH_ENVIRONMENT

FLAGS
-a, --api=<value> [default: https://edge.api.flagsmith.com/api/v1/] The
API URL to fetch the feature flags from
-e, --entity=<option> [default: flags] The entity to fetch, this will either
be the flags or an environment document used for [local
evaluation](https://docs.flagsmith.com/clients/server-s
ide#local-evaluation-mode-network-behaviour).
-a, --api=<value> [default: https://edge.api.flagsmith.com/api/v1/] The API URL to fetch the feature flags from
-e, --entity=<option> [default: flags] The entity to fetch, this will either be the flags or an environment document
used for [local evaluation](https://docs.flagsmith.com/clients/server-side#local-evaluation-mod
e-network-behaviour).
<options: flags|environment>
-o, --output=<value> [default: ./flagsmith.json] The file path output
-p, --pretty Prettify the output JSON

IDENTITY FLAGS
-i, --identity=<value> The identity for which to fetch
feature flags
-t, --trait=<trait_key>=<trait_value>... Trait key-value pair, separated by
an equals sign (=)
-i, --identity=<value> The identity for which to fetch feature flags
-t, --trait=<trait_key>=<trait_value>... Trait key-value pair, separated by an equals sign (=)

DESCRIPTION
Retrieve flagsmith features from the Flagsmith API and output them to a file.
Expand All @@ -116,22 +148,32 @@ EXAMPLES
$ flagsmith get -p
```

_See code: [dist/commands/get/index.ts](https://github.com/Flagsmith/flagsmith-cli/blob/v0.1.4/dist/commands/get/index.ts)_
_See code: [src/commands/get/index.ts](https://github.com/Flagsmith/flagsmith-cli/blob/v0.3.0/src/commands/get/index.ts)_

## `flagsmith help [COMMANDS]`

Display help for flagsmith.

```
USAGE
$ flagsmith help [COMMANDS] [-n]
$ flagsmith help [COMMANDS...] [-n]

ARGUMENTS
COMMANDS Command to show help for.
COMMANDS... Command to show help for.

FLAGS
-n, --nested-commands Include all nested commands in the output.

DESCRIPTION
Display help for flagsmith.
```

_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v5.2.20/src/commands/help.ts)_

### Type generation examples

[1 - Adding a remote config.mov](1%20-%20Adding%20a%20remote%20config.mov)

[2 - Creating a new flag.mov](2%20-%20Creating%20a%20new%20flag.mov)

[3 - Dry run removing flag.mov](3%20-%20Dry%20run%20removing%20flag.mov)
16 changes: 16 additions & 0 deletions example/flagsmith.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export interface FlagsmithTypes {
json_flag: JsonFlag;
number_flag: number;
string_flag: string;
}

export interface JsonFlag {
first_name: string;
last_name: string;
address: Address;
}

export interface Address {
line_1: string;
line_2: string;
}
Loading