Skip to content

Commit

Permalink
docs: Cleaning up the example files after e2e testing.
Browse files Browse the repository at this point in the history
  • Loading branch information
pattobrien committed Feb 14, 2024
1 parent adfdb8c commit eb94534
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 54 deletions.
4 changes: 4 additions & 0 deletions example/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
include: package:lints/recommended.yaml

analyzer:
enable-experiment:
- inline-class

linter:
rules:
prefer_relative_imports: true
11 changes: 2 additions & 9 deletions example/lib/runner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,11 @@ class GitRunner extends _$GitRunner {
/// The name of the branch to be merged into the current branch.
required String branch,

// /// Pass merge strategy specific option through to the merge strategy.
/// Pass merge strategy specific option through to the merge strategy.
MergeStrategy strategy = MergeStrategy.ort,

/// Perform the merge and commit the result.
@Flag() bool? commit,
@Option(hide: true, parser: specialDurationParser) Duration? uri,
@MultiOption(allowed: [1, 2, 3]) int? ff,
Set<int> someSet = const {1, 2, 3},
bool? commit,
}) async {
print('Merging branch $branch');
if (commit == true) {
Expand All @@ -34,7 +31,3 @@ class GitRunner extends _$GitRunner {
}

enum MergeStrategy { ort, recursive, resolve, octopus, ours, subtree }

Duration specialDurationParser(String input) {
return Duration(seconds: int.parse(input));
}
33 changes: 1 addition & 32 deletions example/lib/runner.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion example/lib/stash.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class StashSubcommand extends _$StashSubcommand {
@cliCommand
Future<void> push(
String message, {
@Option(help: 'Whether to include untracked files.', abbr: 'u')
/// Whether to include untracked files.
bool includeUntracked = false,
}) async {
print('Stashing changes with message: $message');
Expand Down
2 changes: 0 additions & 2 deletions example/lib/stash.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,17 @@ class TypeParserExpressionBuilder {
// if the element is a extension type, get the extension type erasure
// to get the underlying type, then get the corresponding parser
// by calling `getParserForParameter` recursively.
final isExtensionType = paramType.extensionTypeErasure != paramType;
if (isExtensionType) {
// final erasure = type.extensionTypeErasure;
// return getParserForParameter(element, erasure);
throw InvalidGenerationSource(
'Extension types are not supported by `cli-gen` yet.',
element: element,
todo: 'Please use a supported type',
);
}
// final isExtensionType = paramType.extensionTypeErasure != paramType;
// if (isExtensionType) {
// // example: if `FooExtensionType` has an actualType of `int`,
// // then the parser would be `FooExtensionType.parse`.

// // throw InvalidGenerationSource(
// // 'Extension types are not supported by `cli-gen` yet.',
// // element: element,
// // todo: 'Please use a supported type',
// // );
// }

throw InvalidGenerationSource(
'`${paramType.element!.name}` is not a supported type for arg parsing.',
Expand Down
18 changes: 18 additions & 0 deletions src/cli_gen/lib/src/analysis/utils/get_parameter_ast_node.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/element/element.dart';
import 'package:build/build.dart';
import 'package:source_gen/source_gen.dart';

extension ParameterAstNodeX on ParameterElement {
Future<FormalParameter> asAstNode(Resolver resolver) async {
final result = await resolver.astNodeFor(this);
if (result is! FormalParameter) {
throw InvalidGenerationSourceError(
'Expected a FormalParameter, but got $result',
element: this,
);
}

return result;
}
}

0 comments on commit eb94534

Please sign in to comment.