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.52 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 segments_repository_1 = require("../../repositories/segments.repository");
class SegmentsList extends core_1.Command {
async run() {
const { flags: { profile, apiBaseUrl, limit, offset, dataSourceId, }, } = await this.parse(SegmentsList);
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 repo = new segments_repository_1.SegmentsRepository({
apiKey,
apiBaseUrl: baseUrlUsed,
});
const segments = await repo.listSegments(limit, offset, dataSourceId);
this.logJson(segments);
}
}
exports.default = SegmentsList;
SegmentsList.description = 'Get all segments used during experiment analysis';
SegmentsList.examples = [
'<%= config.bin %> <%= command.id %>',
];
SegmentsList.flags = {
...cli_1.baseGrowthBookCliFlags,
...cli_1.paginationCliFlags,
dataSourceId: core_1.Flags.string({
description: 'Data source ID to filter by',
required: false,
}),
};
SegmentsList.args = {};