console_cmd 1.0.5

  • Readme
  • Changelog
  • Installing
  • 55

console_cmd #

a series method for developing console application

about line-move, color text and clear method

Usage #

Latest version : 1.0.5

add in pubspec.yaml

dependencies:
  console_cmd: ^1.0.5

ANSIPrinter #

demo1

class ANSIPrinter {
    /// Output RGB Color text
    /// - [text] : text you want output
    /// - [breakLine] : whether break line after output
    /// - [fColor] : foreground color
    /// - [fGray] : foreground color's grey scale value
    /// - [bColor] : background color
    /// - [bGray] : background color's grey scale value
    void printRGB(String text, {bool breakLine = true, int fColor, double fGray, int bColor, double bGray});

    /// Output terminal text
    /// - [text] : text you want output
    /// - [breakLine] : whether break line after output
    void print(String text, {bool breakLine = true});
}

ANSICursor #

demo2

class ANSICursor {
    /// Move cursor up # lines
    /// - [lineCount] : line count
    /// - [beginOfLine] : move to line-start
    void upLine({int lineCount = 1, bool beginOfLine = true})
    
    /// Move cursor down # lines
    /// - [lineCount] : line count
    /// - [beginOfLine] : move to line-start
    void downLine({int lineCount = 1, bool beginOfLine = true})
    
    /// Move cursor right # space
    /// - [spaceCount] : space count
    void goRight({int spaceCount = 1})
    
    /// Move cursor left # space
    /// - [spaceCount] : space count
    void goLeft({int spaceCount = 1})
    
    /// Move cursor to line-start
    void beginLine()

	/// Locate the cursor at specify point
	/// - [point] : specify cursor point
	void locateCursor({ANSICursorPoint point})

    /// Store current cursor position
    /// Return the cursor point index in stored-point list
    ///
    /// * Note that !
    ///
    /// Screen will screen when output a lots message, so some old `stored-point`
    /// may be invalid, because it record the old point not now.
    ///
    Future<int> storeCursorPoint();

    /// Restore to position saved before.
	/// [storePointIdx] : stored-point index, return by [storeCursorPoint]. if this value is `-1`,
	/// means restore to the previous stored-point.
	///
	/// [popBefore] : pop all point stored after restored point
	///
	void restoreToSavePosition({int storePointIdx = -1, bool popBefore = true})
}


ANSIErase #

demo3


class ANSIErase {
    /// Clear the screen and home cursor
    void clearScreen()
    
    /// Clear line until end
    /// - [beginOfLine] : whether clear whole line
    void clearLine({bool beginOfLine = true})
}

StdinManager #

class StdinManager {
    /// Insert stdin observer, the new one will grab data stream
	/// for own use, until next observer come or close by itself
	StdinSubscription insertObserver(StdinObserver observer)

    /// Close stdin stream
	void close()
}

Note that #

Program must run in the terminal or cmd,if not take effect

e.g. "dart xxx.dart" in your terminal instead of IDE run

1.0.0 #

  • First Version !

1.0.1 #

  • Add ANSIPrinter、ANSICursor、ANSIErase、StdinManager

1.0.2 #

  • Add demos, and format code

1.0.3 #

  • Add description

1.0.4 #

  • Allow ANSIPrinter print when not support Ansi Escapes

1.0.5 #

  • Allow ANSIPrinter print when not support Ansi Escapes

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  console_cmd: ^1.0.5

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:console_cmd/console_cmd.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
10
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
55
Learn more about scoring.

We analyzed this package on May 24, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.1
  • pana: 0.13.8-dev

Health suggestions

Format lib/src/constants.dart.

Run dartfmt to format lib/src/constants.dart.

Format lib/src/cursor.dart.

Run dartfmt to format lib/src/cursor.dart.

Format lib/src/erase.dart.

Run dartfmt to format lib/src/erase.dart.

Format lib/src/print.dart.

Run dartfmt to format lib/src/print.dart.

Format lib/src/stdin.dart.

Run dartfmt to format lib/src/stdin.dart.

Maintenance suggestions

Maintain an example.

None of the files in the package's example/ directory matches known example patterns.

Common filename patterns include main.dart, example.dart, and console_cmd.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.2.0 <3.0.0
Dev dependencies
pedantic ^1.8.0
test ^1.6.0