UNPKG

growthbook

Version:

The GrowthBook command-line interface (CLI) for working with the GrowthBook A/B testing, feature flagging, and experimentation platform

36 lines (35 loc) 1.42 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const core_1 = require("@oclif/core"); const constants_1 = require("../../utils/constants"); const config_1 = require("../../utils/config"); const cli_1 = require("../../utils/cli"); const features_repository_1 = require("../../repositories/features.repository"); class FeaturesGet extends core_1.Command { async run() { const { args: { featureKey, }, flags: { profile, apiBaseUrl, }, } = await this.parse(FeaturesGet); const profileUsed = profile || constants_1.DEFAULT_GROWTHBOOK_PROFILE; const { apiKey, apiBaseUrl: configApiBaseUrl } = (0, config_1.getGrowthBookProfileConfigAndThrowForCommand)(profileUsed, this); const baseUrlUsed = apiBaseUrl || configApiBaseUrl || constants_1.DEFAULT_GROWTHBOOK_BASE_URL; const featuresRepo = new features_repository_1.FeaturesRepository({ apiKey, apiBaseUrl: baseUrlUsed, }); const feature = await featuresRepo.getFeature(featureKey); this.logJson(feature); } } exports.default = FeaturesGet; FeaturesGet.description = 'Get a feature by key'; FeaturesGet.examples = [ '<%= config.bin %> <%= command.id %>', ]; FeaturesGet.flags = { ...cli_1.baseGrowthBookCliFlags, }; FeaturesGet.args = { featureKey: core_1.Args.string({ description: 'Feature key', required: true, }), };