executable.dart 3.5 KB
Newer Older
1 2 3 4
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

5 6
import 'dart:async';

7
import 'runner.dart' as runner;
8 9 10 11 12 13
import 'src/base/context.dart';
// The build_runner code generation is provided here to make it easier to
// avoid introducing the dependency into google3. Not all build* packages
// are synced internally.
import 'src/build_runner/build_runner.dart';
import 'src/codegen.dart';
Hixie's avatar
Hixie committed
14
import 'src/commands/analyze.dart';
15
import 'src/commands/attach.dart';
16
import 'src/commands/build.dart';
17
import 'src/commands/channel.dart';
18
import 'src/commands/clean.dart';
19
import 'src/commands/config.dart';
20
import 'src/commands/create.dart';
Devon Carew's avatar
Devon Carew committed
21
import 'src/commands/daemon.dart';
22
import 'src/commands/devices.dart';
23
import 'src/commands/doctor.dart';
yjbanov's avatar
yjbanov committed
24
import 'src/commands/drive.dart';
25
import 'src/commands/emulators.dart';
26
import 'src/commands/format.dart';
27
import 'src/commands/generate.dart';
28
import 'src/commands/ide_config.dart';
29
import 'src/commands/inject_plugins.dart';
30 31
import 'src/commands/install.dart';
import 'src/commands/logs.dart';
32
import 'src/commands/make_host_app_editable.dart';
33
import 'src/commands/packages.dart';
34
import 'src/commands/precache.dart';
35
import 'src/commands/run.dart';
Devon Carew's avatar
Devon Carew committed
36
import 'src/commands/screenshot.dart';
37
import 'src/commands/shell_completion.dart';
38
import 'src/commands/test.dart';
39
import 'src/commands/train.dart';
40
import 'src/commands/unpack.dart';
41
import 'src/commands/update_packages.dart';
42
import 'src/commands/upgrade.dart';
43
import 'src/commands/version.dart';
44
import 'src/runner/flutter_command.dart';
45

46 47
/// Main entry point for commands.
///
48
/// This function is intended to be used from the `flutter` command line tool.
49
Future<void> main(List<String> args) async {
50
  final bool verbose = args.contains('-v') || args.contains('--verbose');
51 52 53

  final bool doctor = (args.isNotEmpty && args.first == 'doctor') ||
      (args.length == 2 && verbose && args.last == 'doctor');
54
  final bool help = args.contains('-h') || args.contains('--help') ||
55
      (args.isNotEmpty && args.first == 'help') || (args.length == 1 && verbose);
56
  final bool muteCommandLogging = help || doctor;
57
  final bool verboseHelp = help && verbose;
Devon Carew's avatar
Devon Carew committed
58

59
  await runner.run(args, <FlutterCommand>[
60 61 62 63 64 65
    AnalyzeCommand(verboseHelp: verboseHelp),
    AttachCommand(verboseHelp: verboseHelp),
    BuildCommand(verboseHelp: verboseHelp),
    ChannelCommand(verboseHelp: verboseHelp),
    CleanCommand(),
    ConfigCommand(verboseHelp: verboseHelp),
66
    CreateCommand(),
67 68 69 70 71 72
    DaemonCommand(hidden: !verboseHelp),
    DevicesCommand(),
    DoctorCommand(verbose: verbose),
    DriveCommand(),
    EmulatorsCommand(),
    FormatCommand(),
73
    GenerateCommand(),
74 75 76 77
    IdeConfigCommand(hidden: !verboseHelp),
    InjectPluginsCommand(hidden: !verboseHelp),
    InstallCommand(),
    LogsCommand(),
78
    MakeHostAppEditableCommand(),
79 80 81 82 83 84
    PackagesCommand(),
    PrecacheCommand(),
    RunCommand(verboseHelp: verboseHelp),
    ScreenshotCommand(),
    ShellCompletionCommand(),
    TestCommand(verboseHelp: verboseHelp),
85
    TrainingCommand(),
86
    UnpackCommand(),
87 88
    UpdatePackagesCommand(hidden: !verboseHelp),
    UpgradeCommand(),
89
    VersionCommand(),
90 91
  ], verbose: verbose,
     muteCommandLogging: muteCommandLogging,
92 93 94 95
     verboseHelp: verboseHelp,
     overrides: <Type, Generator>{
       // The build runner instance is not supported in google3 because
       // the build runner packages are not synced internally.
96
       CodeGenerator: () => const BuildRunner(),
97
     });
98
}