precache.dart 915 Bytes
Newer Older
1 2 3 4 5 6
// Copyright 2016 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.

import 'dart:async';

7
import '../globals.dart';
8
import '../runner/flutter_command.dart';
9

10
class PrecacheCommand extends FlutterCommand {
11 12 13 14 15
  PrecacheCommand() {
    argParser.addFlag('all-platforms', abbr: 'a', negatable: false,
        help: 'Precache artifacts for all platforms.');
  }

16 17 18 19 20 21 22
  @override
  final String name = 'precache';

  @override
  final String description = 'Populates the Flutter tool\'s cache of binary artifacts.';

  @override
23 24 25 26
  bool get requiresProjectRoot => false;

  @override
  Future<int> runInProject() async {
27 28 29
    if (argResults['all-platforms'])
      cache.includeAllPlatforms = true;

30
    if (cache.isUpToDate())
31
      printStatus('Already up-to-date.');
32 33 34
    else
      await cache.updateAll();

35 36 37
    return 0;
  }
}