dart_console
표준 라이브러리가 제공하는 것보다 입력/출력에 대해 더 많은 제어가 필요한 명령줄 애플리케이션을 위한 보조 라이브러리입니다.
콘솔 애플리케이션을 작성하기 위한 Dart 라이브러리
아래는 영문 원문 스냅샷입니다. 최신 내용은 GitHub에서 확인하세요.
A Dart library for building console applications.
pub package Language Build codecov
This library contains a variety of useful functions for console application development, including:
dart:io library.The library has been used to implement a Dart version of the
Kilo text editor; when compiled with Dart it results in a self-contained
kilo executable. The library is sufficient for a reasonably complete set of
usage, including readline-style CLI and basic text games.
The library assumes a terminal that recognizes and implements common ANSI escape sequences. The package has been tested on macOS, Linux and Windows 10. Note that Windows did not support ANSI escape sequences in earlier versions.
The library uses the win32 package for accessing the Win32 API through FFI. That package contains many examples of using Dart FFI for more complex examples.
A simple example for the dart_console package:
import 'package:dart_console/dart_console.dart';
main() {
final console = Console();
console.clearScreen();
console.resetCursorPosition();
console.writeLine(
'Console size is ${console.windowWidth} cols and ${console.windowHeight} rows.',
TextAlignment.center,
);
console.writeLine();
return 0;
}
More comprehensive demos of the Console class are provided, as follows:
| Example | Description |
|---|---|
demo.dart |
Suite of test demos that showcase various capabilities |
main.dart |
Basic demo of how to get started with the dart_console |
keys.dart |
Demonstrates how dart_console processes control characters |
readline.dart |
Sample command-line interface / REPL |
kilo.dart |
Rudimentary text editor |
life.dart |
Game of Life |
table.dart |
Demonstrates tabular data display |
calendar.dart |
Prints a monthly calendar on the screen |
Special thanks to Matt Sullivan (@mjohnsullivan) and Samir Jindel (@sjindel-google) for their help in explaining FFI to me when it was first introduced and still undocumented.
Thanks to @erf for contributing the Game of Life example.
Please file feature requests and bugs at the issue tracker.