Skip to content

Commit 95fa9e3

Browse files
authored
Less chatty (flutter#6213)
* make flutter create less chatty * output generated file count; mention lib/main.dart
1 parent b00e6cd commit 95fa9e3

File tree

3 files changed

+24
-12
lines changed

3 files changed

+24
-12
lines changed

packages/flutter_tools/lib/src/commands/create.dart

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,24 +82,27 @@ class CreateCommand extends FlutterCommand {
8282

8383
Directory projectDir = new Directory(argResults.rest.first);
8484
String dirPath = path.normalize(projectDir.absolute.path);
85+
String relativePath = path.relative(dirPath);
8586
String projectName = _normalizeProjectName(path.basename(dirPath));
8687

8788
if (_validateProjectDir(dirPath) != null) {
8889
printError(_validateProjectDir(dirPath));
8990
return 1;
9091
}
92+
9193
if (_validateProjectName(projectName) != null) {
9294
printError(_validateProjectName(projectName));
9395
return 1;
9496
}
9597

96-
_renderTemplates(
98+
int generatedCount = _renderTemplates(
9799
projectName,
98100
argResults['description'],
99101
dirPath,
100102
flutterPackagesDirectory,
101103
renderDriverTest: argResults['with-driver-test']
102104
);
105+
printStatus('Wrote $generatedCount files.');
103106

104107
printStatus('');
105108

@@ -119,8 +122,8 @@ class CreateCommand extends FlutterCommand {
119122
printStatus('''
120123
All done! In order to run your application, type:
121124
122-
\$ cd $dirPath
123-
\$ flutter run
125+
\$ cd $relativePath
126+
\$ flutter run lib/main.dart
124127
''');
125128
} else {
126129
printStatus("You'll need to install additional components before you can run "
@@ -132,21 +135,21 @@ All done! In order to run your application, type:
132135
printStatus('');
133136
printStatus("After installing components, run 'flutter doctor' in order to "
134137
"re-validate your setup.");
135-
printStatus("When complete, type 'flutter run' from the '$dirPath' "
138+
printStatus("When complete, type 'flutter run lib/main.dart' from the '$relativePath' "
136139
"directory in order to launch your app.");
137140
}
138141

139142
return 0;
140143
}
141144

142-
void _renderTemplates(String projectName, String projectDescription, String dirPath,
145+
int _renderTemplates(String projectName, String projectDescription, String dirPath,
143146
String flutterPackagesDirectory, { bool renderDriverTest: false }) {
144147
new Directory(dirPath).createSync(recursive: true);
145148

146149
flutterPackagesDirectory = path.normalize(flutterPackagesDirectory);
147150
flutterPackagesDirectory = _relativePath(from: dirPath, to: flutterPackagesDirectory);
148151

149-
printStatus('Creating project ${path.basename(projectName)}:');
152+
printStatus('Creating project ${path.relative(dirPath)}...');
150153

151154
Map<String, dynamic> templateContext = <String, dynamic>{
152155
'projectName': projectName,
@@ -157,18 +160,22 @@ All done! In order to run your application, type:
157160
'androidMinApiLevel': android.minApiLevel
158161
};
159162

163+
int fileCount = 0;
164+
160165
if (renderDriverTest)
161166
templateContext['withDriverTest?'] = <String, dynamic>{};
162167

163168
Template createTemplate = new Template.fromName('create');
164-
createTemplate.render(new Directory(dirPath), templateContext,
169+
fileCount += createTemplate.render(new Directory(dirPath), templateContext,
165170
overwriteExisting: false);
166171

167172
if (renderDriverTest) {
168173
Template driverTemplate = new Template.fromName('driver');
169-
driverTemplate.render(new Directory(path.join(dirPath, 'test_driver')),
174+
fileCount += driverTemplate.render(new Directory(path.join(dirPath, 'test_driver')),
170175
templateContext, overwriteExisting: false);
171176
}
177+
178+
return fileCount;
172179
}
173180
}
174181

packages/flutter_tools/lib/src/doctor.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class Doctor {
9292

9393
if (!allGood) {
9494
buffer.writeln();
95-
buffer.write('Run "flutter doctor" for information about installing additional components.');
95+
buffer.writeln('Run "flutter doctor" for information about installing additional components.');
9696
}
9797

9898
return buffer.toString();

packages/flutter_tools/lib/src/template.dart

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,10 @@ class Template {
6060

6161
Map<String /* relative */, String /* absolute source */> _templateFilePaths;
6262

63-
void render(Directory destination, Map<String, dynamic> context,
63+
int render(Directory destination, Map<String, dynamic> context,
6464
{ bool overwriteExisting: true }) {
6565
destination.createSync(recursive: true);
66+
int fileCount = 0;
6667

6768
String destinationDirPath = destination.absolute.path;
6869

@@ -82,13 +83,15 @@ class Template {
8283
printStatus(' $relativePathForLogging (overwritten)');
8384
} else {
8485
// The file exists but we cannot overwrite it, move on.
85-
printStatus(' $relativePathForLogging (existing - skipped)');
86+
printTrace(' $relativePathForLogging (existing - skipped)');
8687
return;
8788
}
8889
} else {
89-
printStatus(' $relativePathForLogging');
90+
printTrace(' $relativePathForLogging');
9091
}
9192

93+
fileCount++;
94+
9295
finalDestinationFile.createSync(recursive: true);
9396
File sourceFile = new File(absoluteSrcPath);
9497

@@ -118,6 +121,8 @@ class Template {
118121

119122
sourceFile.copySync(finalDestinationFile.path);
120123
});
124+
125+
return fileCount;
121126
}
122127
}
123128

0 commit comments

Comments
 (0)