precache.dart 859 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
  Future<int> runCommand() async {
24 25 26
    if (argResults['all-platforms'])
      cache.includeAllPlatforms = true;

27
    if (cache.isUpToDate())
28
      printStatus('Already up-to-date.');
29 30 31
    else
      await cache.updateAll();

32 33 34
    return 0;
  }
}