|
4 | 4 |
|
5 | 5 | import 'package:args/args.dart';
|
6 | 6 |
|
7 |
| -final argParser = ArgParser(allowTrailingOptions: false) |
8 |
| - ..addOption( |
9 |
| - dartSdkOption, |
10 |
| - help: |
11 |
| - 'The path to the root of the desired Dart SDK. Defaults to the ' |
12 |
| - 'DART_SDK environment variable.', |
13 |
| - ) |
14 |
| - ..addOption( |
15 |
| - flutterSdkOption, |
16 |
| - help: |
17 |
| - 'The path to the root of the desired Flutter SDK. Defaults to ' |
18 |
| - 'the FLUTTER_SDK environment variable, then searching up from ' |
19 |
| - 'the Dart SDK.', |
20 |
| - ) |
21 |
| - ..addFlag( |
22 |
| - forceRootsFallbackFlag, |
23 |
| - negatable: true, |
24 |
| - defaultsTo: false, |
25 |
| - help: |
26 |
| - 'Forces a behavior for project roots which uses MCP tools ' |
27 |
| - 'instead of the native MCP roots. This can be helpful for ' |
28 |
| - 'clients like cursor which claim to have roots support but do ' |
29 |
| - 'not actually support it.', |
30 |
| - ) |
31 |
| - ..addOption( |
32 |
| - logFileOption, |
33 |
| - help: |
34 |
| - 'Path to a file to log all MPC protocol traffic to. File will be ' |
35 |
| - 'overwritten if it exists.', |
36 |
| - ) |
37 |
| - ..addFlag(helpFlag, abbr: 'h', help: 'Show usage text'); |
| 7 | +/// Creates an arg parser for th MCP server. |
| 8 | +/// |
| 9 | +/// The `--help` option is only included if [includeHelp] is `true`. |
| 10 | +/// |
| 11 | +/// Passing no options results in the default arg parser. |
| 12 | +ArgParser createArgParser({ |
| 13 | + bool includeHelp = true, |
| 14 | + bool allowTrailingOptions = false, |
| 15 | + int? usageLineLength, |
| 16 | +}) { |
| 17 | + final parser = |
| 18 | + ArgParser( |
| 19 | + allowTrailingOptions: allowTrailingOptions, |
| 20 | + usageLineLength: usageLineLength, |
| 21 | + ) |
| 22 | + ..addOption( |
| 23 | + dartSdkOption, |
| 24 | + help: |
| 25 | + 'The path to the root of the desired Dart SDK. Defaults to the ' |
| 26 | + 'DART_SDK environment variable.', |
| 27 | + ) |
| 28 | + ..addOption( |
| 29 | + flutterSdkOption, |
| 30 | + help: |
| 31 | + 'The path to the root of the desired Flutter SDK. Defaults to ' |
| 32 | + 'the FLUTTER_SDK environment variable, then searching up from ' |
| 33 | + 'the Dart SDK.', |
| 34 | + ) |
| 35 | + ..addFlag( |
| 36 | + forceRootsFallbackFlag, |
| 37 | + negatable: true, |
| 38 | + defaultsTo: false, |
| 39 | + help: |
| 40 | + 'Forces a behavior for project roots which uses MCP tools ' |
| 41 | + 'instead of the native MCP roots. This can be helpful for ' |
| 42 | + 'clients like cursor which claim to have roots support but do ' |
| 43 | + 'not actually support it.', |
| 44 | + ) |
| 45 | + ..addOption( |
| 46 | + logFileOption, |
| 47 | + help: |
| 48 | + 'Path to a file to log all MPC protocol traffic to. File will be ' |
| 49 | + 'overwritten if it exists.', |
| 50 | + ); |
| 51 | + |
| 52 | + if (includeHelp) parser.addFlag(helpFlag, abbr: 'h', help: 'Show usage text'); |
| 53 | + return parser; |
| 54 | +} |
38 | 55 |
|
39 | 56 | const dartSdkOption = 'dart-sdk';
|
40 | 57 | const flutterSdkOption = 'flutter-sdk';
|
|
0 commit comments