io 1.0.4 copy "io: ^1.0.4" to clipboard
io: ^1.0.4 copied to clipboard

Utilities for the Dart VM Runtime including support for ANSI colors, file copying, and standard exit code values.

example/example.dart

// Copyright 2017, the Dart project authors.  Please see the AUTHORS file
// for details. 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:math';

import 'package:io/ansi.dart';

/// Prints a sample of all of the `AnsiCode` values.
void main(List<String> args) {
  final forScript = args.contains('--for-script');

  if (!ansiOutputEnabled) {
    print('`ansiOutputEnabled` is `false`.');
    print("Don't expect pretty output.");
  }
  _preview('Foreground', foregroundColors, forScript);
  _preview('Background', backgroundColors, forScript);
  _preview('Styles', styles, forScript);
}

void _preview(String name, List<AnsiCode> values, bool forScript) {
  print('');
  final longest = values.map((ac) => ac.name.length).reduce(max);

  print(wrapWith('** $name **', [styleBold, styleUnderlined]));
  for (var code in values) {
    final header =
        '${code.name.padRight(longest)} ${code.code.toString().padLeft(3)}';

    print("$header: ${code.wrap('Sample', forScript: forScript)}");
  }
}
57
likes
160
pub points
98%
popularity

Publisher

verified publishertools.dart.dev

Utilities for the Dart VM Runtime including support for ANSI colors, file copying, and standard exit code values.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

meta, path, string_scanner

More

Packages that depend on io