Skip to content

Commit aafb464

Browse files
committed
feat: add configuration tooling commands
1 parent f0b1192 commit aafb464

7 files changed

Lines changed: 795 additions & 21 deletions

File tree

CONFIGURATION_STRATEGY.md

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Behavior:
3737
- Does not enforce layers/modules unless they are declared
3838

3939
Use this level when the user wants a quick signal and has not agreed on project
40-
architecture boundaries yet.
40+
architecture boundaries yet. No YAML file is required.
4141

4242
### Level 1: Basic Project Config
4343

@@ -83,6 +83,13 @@ rules:
8383
8484
Use this level when teams want stable thresholds or custom excludes.
8585
86+
Create it with:
87+
88+
```bash
89+
flutterguard init
90+
flutterguard config doctor
91+
```
92+
8693
### Level 2: CI Gate Config
8794

8895
Best for pull requests and release checks.
@@ -96,11 +103,18 @@ Recommended policy:
96103
- Start with `--fail-on high`
97104
- Add `--min-score 80` once the baseline is clean enough
98105
- Avoid `--fail-on low` early in adoption because it can create noisy rollouts
106+
- Run `flutterguard config doctor` before adding CI gates
99107

100108
### Level 3: Architecture Config
101109

102110
Best when the project has agreed boundaries.
103111

112+
Create a starter template with:
113+
114+
```bash
115+
flutterguard init --with-architecture
116+
```
117+
104118
```yaml
105119
architecture:
106120
layers:
@@ -154,9 +168,9 @@ CLI responses should stay short and operational:
154168
Avoid long explanations in command output. Point to this guide when the user
155169
needs examples or architecture detail.
156170

157-
## Future Enhancements
171+
## Config Tooling
158172

159-
The next usability improvements should be command-level helpers:
173+
The core configuration helpers are available as CLI commands:
160174

161175
- `flutterguard init`: write a minimal `flutterguard.yaml`
162176
- `flutterguard init --with-architecture`: write a layered/module template
@@ -165,4 +179,4 @@ The next usability improvements should be command-level helpers:
165179
architecture overlap
166180

167181
These commands are preferable to adding more prose to `scan`, because they keep
168-
the scan output focused while still making configuration discoverable.
182+
scan output focused while still making configuration discoverable.

README.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,13 @@ flutterguard --help
143143
# Scan the current directory
144144
flutterguard scan
145145

146+
# Create and validate a starter config
147+
flutterguard init
148+
flutterguard config doctor
149+
150+
# Inspect the merged effective config
151+
flutterguard config print
152+
146153
# Scan a specific project
147154
flutterguard scan ./my_flutter_app # macOS / Linux
148155
flutterguard scan .\my_flutter_app # Windows
@@ -174,6 +181,10 @@ Commands:
174181
| Command | Description |
175182
|---------|-------------|
176183
| `flutterguard scan [<path>]` | Scan a project (path defaults to current directory) |
184+
| `flutterguard init` | Create a starter `flutterguard.yaml` |
185+
| `flutterguard init --with-architecture` | Create config with architecture layer/module templates |
186+
| `flutterguard config print` | Print the merged effective configuration |
187+
| `flutterguard config doctor` | Validate config, globs, and architecture references |
177188
| `flutterguard --help` / `-h` | Show usage |
178189
| `flutterguard --version` / `-V` | Show version |
179190

@@ -218,9 +229,10 @@ Create `flutterguard.yaml` in your project root.
218229
Recommended strategy:
219230

220231
1. Start with zero config: `flutterguard scan`.
221-
2. Add a basic config only when you need custom thresholds or excludes.
222-
3. Add CI gates with `--format json --fail-on high --min-score 80`.
223-
4. Add architecture layers/modules only after project boundaries are agreed.
232+
2. Run `flutterguard init` when you need custom thresholds or excludes.
233+
3. Use `flutterguard config print` to inspect merged defaults.
234+
4. Use `flutterguard config doctor` before enabling CI gates.
235+
5. Add architecture layers/modules only after project boundaries are agreed.
224236

225237
For the full decision model, see [Configuration Strategy](CONFIGURATION_STRATEGY.md).
226238

README.zh.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,13 @@ flutterguard --help
142142
# 扫描当前目录
143143
flutterguard scan
144144

145+
# 创建并检查基础配置
146+
flutterguard init
147+
flutterguard config doctor
148+
149+
# 查看合并后的有效配置
150+
flutterguard config print
151+
145152
# 扫描指定项目
146153
flutterguard scan ./my_flutter_app # macOS / Linux
147154
flutterguard scan .\my_flutter_app # Windows
@@ -173,6 +180,10 @@ flutterguard scan examples/scan_demo
173180
| 命令 | 说明 |
174181
|------|------|
175182
| `flutterguard scan [<path>]` | 扫描项目(路径默认为当前目录) |
183+
| `flutterguard init` | 创建基础 `flutterguard.yaml` |
184+
| `flutterguard init --with-architecture` | 创建包含架构层/模块模板的配置 |
185+
| `flutterguard config print` | 输出合并后的有效配置 |
186+
| `flutterguard config doctor` | 检查配置、glob 和架构引用 |
176187
| `flutterguard --help` / `-h` | 显示帮助 |
177188
| `flutterguard --version` / `-V` | 显示版本 |
178189

@@ -217,9 +228,10 @@ FlutterGuard 从当前目录向上遍历,自动发现项目根目录(查找
217228
推荐策略:
218229

219230
1. 先零配置运行:`flutterguard scan`
220-
2. 只有需要自定义阈值或排除文件时,再添加基础配置。
221-
3. CI 场景使用 `--format json --fail-on high --min-score 80`
222-
4. 只有项目边界已经明确时,再添加 architecture layers/modules。
231+
2. 需要自定义阈值或排除文件时,运行 `flutterguard init`
232+
3. 使用 `flutterguard config print` 查看合并后的默认值。
233+
4. 启用 CI 门禁前先运行 `flutterguard config doctor`
234+
5. 只有项目边界已经明确时,再添加 architecture layers/modules。
223235

224236
完整决策模型见 [配置策略](CONFIGURATION_STRATEGY.md)
225237

packages/flutterguard_cli/README.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ dart pub global activate flutterguard_cli
1616
# Scan a Flutter project
1717
flutterguard scan -p /path/to/flutter_project
1818

19+
# Create and validate a starter config
20+
flutterguard init
21+
flutterguard config doctor
22+
1923
# JSON output with CI gate
2024
flutterguard scan -p . --format json --fail-on high --min-score 80
2125
```
@@ -42,8 +46,10 @@ flutterguard scan -p . --format json --fail-on high --min-score 80
4246

4347
Create `flutterguard.yaml` in your project root:
4448

45-
Start without config, then add YAML only when you need custom thresholds,
46-
excludes, CI gates, or explicit architecture boundaries.
49+
Start without config, then run `flutterguard init` only when you need custom
50+
thresholds, excludes, CI gates, or explicit architecture boundaries. Use
51+
`flutterguard config print` to inspect merged defaults and
52+
`flutterguard config doctor` before enabling CI gates.
4753

4854
```yaml
4955
rules:
@@ -73,14 +79,18 @@ If no config file exists, defaults are used (all default rules enabled, no archi
7379
## CLI Reference
7480
7581
```
76-
flutterguard scan [options]
82+
flutterguard scan [<path>] [options]
7783
-p, --path Project path (default: .)
7884
-c, --config Config file (default: flutterguard.yaml)
7985
-f, --format table | json (default: table)
8086
-o, --output Output directory (default: .flutterguard)
8187
-v, --verbose Show detailed context
8288
--fail-on CI gate: none | high | medium | low
8389
--min-score Minimum score threshold 0-100
90+
91+
flutterguard init [--with-architecture] [--force]
92+
flutterguard config print
93+
flutterguard config doctor
8494
```
8595

8696
Exit codes: `0` success, `1` CI gate failed, `2` scan error.

0 commit comments

Comments
 (0)