Skip to content

Commit

Permalink
feat(create): support custom description (#158)
Browse files Browse the repository at this point in the history
  • Loading branch information
denangelov committed Jul 27, 2021
1 parent 7307953 commit b163c49
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 18 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Creates a new very good project in the specified directory.
Usage: very_good create <output directory>
-h, --help Print this usage information.
--project-name The project name for this new Flutter project. This must be a valid dart package name.
--desc The description for this new project.
--org-name The organization for this new Flutter project.
(defaults to "com.example.verygoodcore")
-t, --template The template used to generate this new project.
Expand Down
15 changes: 14 additions & 1 deletion lib/src/commands/create.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ class CreateCommand extends Command<int> {
'This must be a valid dart package name.',
defaultsTo: null,
)
..addOption(
'desc',
help: 'The description for this new project.',
defaultsTo: '',
)
..addOption(
'org-name',
help: 'The organization for this new Flutter project.',
Expand Down Expand Up @@ -91,13 +96,18 @@ class CreateCommand extends Command<int> {
Future<int> run() async {
final outputDirectory = _outputDirectory;
final projectName = _projectName;
final description = _description;
final orgName = _orgName;
final template = _template;
final generateDone = _logger.progress('Bootstrapping');
final generator = await _generator(template.bundle);
final fileCount = await generator.generate(
DirectoryGeneratorTarget(outputDirectory, _logger),
vars: {'project_name': projectName, 'org_name': orgName},
vars: {
'project_name': projectName,
'description': description,
'org_name': orgName
},
);
generateDone('Generated $fileCount file(s)');

Expand All @@ -124,6 +134,9 @@ class CreateCommand extends Command<int> {
return projectName;
}

//// Gets the description for the project
String get _description => _argResults['desc'] as String? ?? '';

/// Gets the organization name.
List<Map<String, String>> get _orgName {
final orgName = _argResults['org-name'] as String? ?? _defaultOrgName;
Expand Down
8 changes: 4 additions & 4 deletions lib/src/templates/very_good_core_bundle.dart

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

Loading

0 comments on commit b163c49

Please sign in to comment.