Skip to content

CLI

bash
npx vue-feature-toggles <command> [options]

The CLI reads configuration directly from your source files — no separate config file needed. It scans for app.use(FeatureToggles, { ... }) and statically extracts flags, meta, expiry, groups, and dependencies.

ts
// main.ts — the CLI reads this automatically
app.use(FeatureToggles, {
  flags: { newDashboard: true, betaSearch: false, checkoutFlow: 'v1' },
  meta: { newDashboard: { owner: 'alice', addedAt: '2024-01-15', ticket: 'PROJ-42' } },
  expiry: { betaBanner: '2025-06-01' },
  groups: { beta: ['betaSearch'] },
  // rules, loader, schedule, variables, userId — dynamic/runtime-only, not parsed by the CLI
})

If you need an explicit override (e.g. in a monorepo), create feature-toggles.config.js in the project root — it takes priority over source scanning:

js
// feature-toggles.config.js  (optional explicit override)
export default {
  flags: { newDashboard: true, betaSearch: false },
  meta: { newDashboard: { owner: 'alice', addedAt: '2024-01-15' } },
}

list — show all flags

bash
npx vue-feature-toggles list

Prints an aligned table with flag name, value, source, owner, addedAt, expiry badge, and group membership.

Flag             Value  Source  Owner      Added       Expiry     Groups
──────────────────────────────────────────────────────────────────────────
newDashboard     true   static  frontend   2025-01-15             layout
betaSearch       false  static  search-…   2025-06-01             beta
checkoutFlow     v1     static  checkout   2025-09-01
christmasBanner  true   static  marketing  2024-11-01  [EXPIRED]

The Source column always reads static — the CLI only ever sees the statically-scanned configuration, not a live app, so it has no way to know whether a flag would actually resolve from rules/loader/a URL override at runtime. Treat it as "declared statically", not as a real-time source resolution.

check — find unknown flag references

bash
npx vue-feature-toggles check
npx vue-feature-toggles check ./src/features
npx vue-feature-toggles check --src src/features

Scans .ts, .tsx, .js, .jsx, .vue files for useFeature(...), useFeatureVariant(...), v-feature="...", and isEnabled/getVariant/setFlag/resetFlag/watchFlag(...) calls. Lists each found reference — ✅ known, ❌ unknown with "did you mean?" suggestion. Exits with code 1 on unknown references — safe for CI.

✅ newDashboard
✅ betaSearch
❌ newCheckout  — unknown flag. Did you mean: checkoutFlow?

The directory to scan can be given either as a positional argument or via --src.

stale — find flags overdue for cleanup

bash
npx vue-feature-toggles stale
npx vue-feature-toggles stale --months 6

Reports boolean true flags whose meta.addedAt is older than --months (default: 3). These are candidates for removal — the feature has been live long enough that the flag is dead code. Variant (string-valued) flags are never reported as stale, regardless of age.

Global options

OptionDefaultDescription
<dir> (positional)(check only)Source directory to scan — alternative to --src
--config <path>(scan source files)Explicit config file override
--root <path>.Project root directory
--src <path>src (check only)Source directory to scan
--months <n>3 (stale only)Age threshold in months