Unverified Commit 4f298e67 authored by matthew-carroll's avatar matthew-carroll Committed by GitHub

Publish make-host-app-editable command with CLI docs. (#22635)

Publish make-host-app-editable command with CLI docs.
parent 655bf6a2
...@@ -3,43 +3,35 @@ ...@@ -3,43 +3,35 @@
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:async'; import 'dart:async';
import 'package:meta/meta.dart';
import '../base/common.dart'; import '../base/common.dart';
import '../project.dart'; import '../project.dart';
import '../runner/flutter_command.dart'; import '../runner/flutter_command.dart';
class MakeHostAppEditableCommand extends FlutterCommand { class MakeHostAppEditableCommand extends FlutterCommand {
MakeHostAppEditableCommand() { MakeHostAppEditableCommand() {
addSubcommand(MakeHostAppEditableAndroidCommand());
addSubcommand(MakeHostAppEditableIosCommand());
}
@override
final String name = 'make-host-app-editable';
@override
final String description = 'Commands for making host apps editable within a Flutter project';
@override
bool get hidden => true;
@override
Future<FlutterCommandResult> runCommand() async => null;
}
abstract class MakeHostAppEditableSubCommand extends FlutterCommand {
MakeHostAppEditableSubCommand() {
requiresPubspecYaml(); requiresPubspecYaml();
argParser.addFlag(
'ios',
help: 'Whether to make this project\'s iOS app editable.',
negatable: false,
);
argParser.addFlag(
'android',
help: 'Whether ot make this project\'s Android app editable.',
negatable: false,
);
} }
FlutterProject _project; FlutterProject _project;
@override @override
@mustCallSuper final String name = 'make-host-app-editable';
Future<FlutterCommandResult> runCommand() async {
await _project.ensureReadyForPlatformSpecificTooling(); @override
return null; final String description = 'Moves host apps from generated directories to non-generated directories so that they can be edited by developers.\n\n'
} 'Use flags to specify which host app to make editable. If no flags are provided then all host apps will be made editable.\n\n'
'Once a host app is made editable, that host app cannot be regenerated by Flutter and it will not receive future template changes.';
@override @override
Future<void> validateCommand() async { Future<void> validateCommand() async {
...@@ -48,36 +40,23 @@ abstract class MakeHostAppEditableSubCommand extends FlutterCommand { ...@@ -48,36 +40,23 @@ abstract class MakeHostAppEditableSubCommand extends FlutterCommand {
if (!_project.isApplication) if (!_project.isApplication)
throw ToolExit("Only projects created using 'flutter create -t application' can have their host apps made editable."); throw ToolExit("Only projects created using 'flutter create -t application' can have their host apps made editable.");
} }
}
class MakeHostAppEditableAndroidCommand extends MakeHostAppEditableSubCommand {
@override
String get name => 'android';
@override
String get description => 'Make an Android host app editable within a Flutter project';
@override
Future<FlutterCommandResult> runCommand() async {
await super.runCommand();
await _project.android.makeHostAppEditable();
return null;
}
}
class MakeHostAppEditableIosCommand extends MakeHostAppEditableSubCommand {
@override
String get name => 'ios';
@override
String get description => 'Make an iOS host app editable within a Flutter project';
@override @override
Future<FlutterCommandResult> runCommand() async { Future<Null> runCommand() async {
await super.runCommand(); await _project.ensureReadyForPlatformSpecificTooling();
await _project.ios.makeHostAppEditable();
return null; final bool isAndroidRequested = argResults['android'];
final bool isIOSRequested = argResults['ios'];
if (isAndroidRequested == isIOSRequested) {
// No flags provided, or both flags provided. Make Android and iOS host
// apps editable.
await _project.android.makeHostAppEditable();
await _project.ios.makeHostAppEditable();
} else if (isAndroidRequested) {
await _project.android.makeHostAppEditable();
} else if (isIOSRequested) {
await _project.ios.makeHostAppEditable();
}
} }
} }
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