CLI Reference

Basic Usage

bash
# Run with default config file
npx fs-guard
# Run with specific preset
npx fs-guard --preset nestjs
# List available presets
npx fs-guard --list

Commands

CommandDescriptionExample
(no args)Validate using config filenpx fs-guard
--preset <name>Use a built-in presetnpx fs-guard --preset react-ts
--listList all available presetsnpx fs-guard --list
--helpShow help messagenpx fs-guard --help
--versionShow versionnpx fs-guard --version

Exit Codes

FS Guard uses standard exit codes for CI integration:

CodeMeaningDescription
0SuccessAll validations passed
1FailureOne or more validations failed
2ErrorConfiguration error or runtime error

CI Integration

Example GitHub Actions workflow:

bash
name: Validate Structure
on: [push, pull_request]
jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- run: npm install
- run: npx fs-guard

npm Scripts

Add to package.json for convenience:

typescript
{
"scripts": {
"validate:structure": "fs-guard",
"validate:nestjs": "fs-guard --preset nestjs"
}
}

Then run with npm:

bash
npm run validate:structure