Declare multiple Flags from a JSON file

Create multiple flags using the CLI

This page contains information on creating multiple flags.

🚧

Notice

Make sure to configure your Flagship CLI with the right scope flag.create before you run the script

Execute the script

Since the script read JSON data in the bash, we used the library jq. For the tutorial to install the library please follow the instructions here

Script

The script simply read the data from the JSON and run loop that execute the flagship command for creating a flag flagship flag create reference

#!/bin/bash

readarray -t name <<< $(jq -r '.[].name' $1)
type=( $(jq -r '.[].type' $1) )
readarray -t description <<< $(jq -r '.[].description' $1)
source=( $(jq -r '.[].source' $1) )

for (( i=0; i<${#name[@]}; i++))
do 
    flagship flag create -d $"{\"name\":\"${name[$i]}\",\"type\":\"${type[$i]}\", \"description\":\"${description[$i]}\", \"source\":\"${source[$i]}\"}"
done

Input schema

In order to execute the script, the input should be a JSON file that respect this schema

[
    {
        "name": "flag_name",
        "type": "flag_type",
        "description": "flag_description",
        "source": "source"
    }
]

type has only

Exemple