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.4 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@oclif/core");
const cli_1 = require("../../utils/cli");
const constants_1 = require("../../utils/constants");
const config_1 = require("../../utils/config");
const metrics_repository_1 = require("../../repositories/metrics.repository");
class MetricsGet extends core_1.Command {
async run() {
const { args: { metricId, }, flags: { profile, apiBaseUrl, }, } = await this.parse(MetricsGet);
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 metricsRepo = new metrics_repository_1.MetricsRepository({
apiKey,
apiBaseUrl: baseUrlUsed,
});
const metric = await metricsRepo.getMetric(metricId);
this.logJson(metric);
}
}
exports.default = MetricsGet;
MetricsGet.description = 'Get a single metric by ID';
MetricsGet.examples = [
'<%= config.bin %> <%= command.id %>',
];
MetricsGet.flags = {
...cli_1.baseGrowthBookCliFlags,
};
MetricsGet.args = {
metricId: core_1.Args.string({
description: 'Metric ID',
required: true,
}),
};