Commit 76d069f9 authored by Devon Carew's avatar Devon Carew

rename the init command to create

parent 06ef620d
...@@ -14,8 +14,8 @@ import 'src/commands/analyze.dart'; ...@@ -14,8 +14,8 @@ import 'src/commands/analyze.dart';
import 'src/commands/apk.dart'; import 'src/commands/apk.dart';
import 'src/commands/build.dart'; import 'src/commands/build.dart';
import 'src/commands/cache.dart'; import 'src/commands/cache.dart';
import 'src/commands/create.dart';
import 'src/commands/daemon.dart'; import 'src/commands/daemon.dart';
import 'src/commands/init.dart';
import 'src/commands/install.dart'; import 'src/commands/install.dart';
import 'src/commands/ios.dart'; import 'src/commands/ios.dart';
import 'src/commands/list.dart'; import 'src/commands/list.dart';
...@@ -60,8 +60,8 @@ Future main(List<String> args) async { ...@@ -60,8 +60,8 @@ Future main(List<String> args) async {
..addCommand(new ApkCommand()) ..addCommand(new ApkCommand())
..addCommand(new BuildCommand()) ..addCommand(new BuildCommand())
..addCommand(new CacheCommand()) ..addCommand(new CacheCommand())
..addCommand(new CreateCommand())
..addCommand(new DaemonCommand()) ..addCommand(new DaemonCommand())
..addCommand(new InitCommand())
..addCommand(new InstallCommand()) ..addCommand(new InstallCommand())
..addCommand(new IOSCommand()) ..addCommand(new IOSCommand())
..addCommand(new ListCommand()) ..addCommand(new ListCommand())
...@@ -75,6 +75,11 @@ Future main(List<String> args) async { ...@@ -75,6 +75,11 @@ Future main(List<String> args) async {
..addCommand(new UpgradeCommand()); ..addCommand(new UpgradeCommand());
return Chain.capture(() async { return Chain.capture(() async {
// Convert `flutter init` invocations to `flutter create` ones.
// TODO(devoncarew): Remove this after a few releases.
if (args.isNotEmpty && args[0] == 'init')
args[0] = 'create';
dynamic result = await runner.run(args); dynamic result = await runner.run(args);
if (result is int) if (result is int)
exit(result); exit(result);
......
...@@ -14,11 +14,11 @@ import '../artifacts.dart'; ...@@ -14,11 +14,11 @@ import '../artifacts.dart';
import '../base/logging.dart'; import '../base/logging.dart';
import '../base/process.dart'; import '../base/process.dart';
class InitCommand extends Command { class CreateCommand extends Command {
final String name = 'init'; final String name = 'create';
final String description = 'Create a new Flutter project.'; final String description = 'Create a new Flutter project.';
InitCommand() { CreateCommand() {
argParser.addOption('out', abbr: 'o', help: 'The output directory.'); argParser.addOption('out', abbr: 'o', help: 'The output directory.');
argParser.addFlag('pub', argParser.addFlag('pub',
defaultsTo: true, defaultsTo: true,
...@@ -46,7 +46,6 @@ class InitCommand extends Command { ...@@ -46,7 +46,6 @@ class InitCommand extends Command {
return 2; return 2;
} }
// TODO: Confirm overwrite of an existing directory with the user.
Directory out = new Directory(argResults['out']); Directory out = new Directory(argResults['out']);
new FlutterSimpleTemplate().generateInto(out, flutterPackagePath); new FlutterSimpleTemplate().generateInto(out, flutterPackagePath);
......
...@@ -7,14 +7,14 @@ import 'dart:io'; ...@@ -7,14 +7,14 @@ import 'dart:io';
import 'package:args/command_runner.dart'; import 'package:args/command_runner.dart';
import 'package:path/path.dart' as path; import 'package:path/path.dart' as path;
import 'package:flutter_tools/src/artifacts.dart'; import 'package:flutter_tools/src/artifacts.dart';
import 'package:flutter_tools/src/commands/init.dart'; import 'package:flutter_tools/src/commands/create.dart';
import 'package:flutter_tools/src/base/process.dart'; import 'package:flutter_tools/src/base/process.dart';
import 'package:test/test.dart'; import 'package:test/test.dart';
main() => defineTests(); main() => defineTests();
defineTests() { defineTests() {
group('init', () { group('create', () {
Directory temp; Directory temp;
setUp(() { setUp(() {
...@@ -31,17 +31,18 @@ defineTests() { ...@@ -31,17 +31,18 @@ defineTests() {
// Verify that we create a project that is well-formed. // Verify that we create a project that is well-formed.
test('flutter-simple', () async { test('flutter-simple', () async {
ArtifactStore.flutterRoot = '../..'; ArtifactStore.flutterRoot = '../..';
InitCommand command = new InitCommand(); CreateCommand command = new CreateCommand();
CommandRunner runner = new CommandRunner('test_flutter', '') CommandRunner runner = new CommandRunner('test_flutter', '')
..addCommand(command); ..addCommand(command);
await runner.run(['init', '--out', temp.path]) await runner.run(['create', '--out', temp.path])
.then((int code) => expect(code, equals(0))); .then((int code) => expect(code, equals(0)));
String mainPath = path.join(temp.path, 'lib', 'main.dart'); String mainPath = path.join(temp.path, 'lib', 'main.dart');
expect(new File(mainPath).existsSync(), true); expect(new File(mainPath).existsSync(), true);
ProcessResult exec = Process.runSync( ProcessResult exec = Process.runSync(
sdkBinaryName('dartanalyzer'), ['--fatal-warnings', mainPath], sdkBinaryName('dartanalyzer'), ['--fatal-warnings', mainPath],
workingDirectory: temp.path); workingDirectory: temp.path
);
if (exec.exitCode != 0) { if (exec.exitCode != 0) {
print(exec.stdout); print(exec.stdout);
print(exec.stderr); print(exec.stderr);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment