easy_tui 3.3.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 51

EasyTUI #

About #

This is a small library for generating text-driven menus in the terminal.

In this library, TUI stands for Text User Interface

Documentation #

  • See CLInvoice for a practical example of its use. Otherwise, see below for a brief guide.
  • Dartdoc has been used document this library and its use.

Examples #

See the examples/ folder.

3.X.Y #

3.3.0 #

  • Fix bug preventing prepend from functioning on TextOptionUIs

3.2.0 #

  • Change the way that preface works in TextFormUIs
    • It functioned differently than TextOptionUI, and it makes more sense to have uniformity.

3.1.0 #

  • Change some text to better reflect the usage of easy_tui

3.0.3 #

  • Use dartfmt on project as per pub.dev's suggestions

3.0.2 #

  • Fix oversight in documentation during refactor

3.0.1 #

  • Fix bug introduced by 3.0.0
    • List<MenuModifier>s were not changed over to Set<MenuModifier>s

3.0.0 #

  • Change data structure for containing modifiers in TextUI
  • Even though this is a MAJOR path revision, the change is actually quite small.

2.X.Y #

2.0.6 #

  • Update documentation to reflect most recent versions

2.0.5 #

  • Remove extraneous dashed lines from TerminalDialogue.PROMPT as introduced by 2.0.4

2.0.4 #

  • Make several things easier to read in the menus

2.0.3 #

  • Fix number-bullets showing when they shouldn't
  • Change order of yes/no error message

2.0.2 #

  • Fix issue with not quitting TextFormUIs

2.0.1 #

  • Improve documentation

2.0.0 #

  • Change reviseAnswers() method signature to return Map<String, String> instead of two List<String>.
    • This change is in hope to solidify the relationship between the questions and the answers

1.X.Y #

1.0.4 #

  • Fix errors in example/main.dart created by the 1.0.3 update

1.0.3 #

  • Update to follow "strict" mode
  • Add more lint options
    • Subsequently update all files to follow linting rules

1.0.2 #

  • Add file to import every class in one go, lib/tui.dart

1.0.1 #

  • Ran dartfmt on all files as suggested by pub
  • I will be doing this whenever I pull into this branch, however the master & etc. branches will remain formatted my way

1.0.0 #

  • Initial release
  • See example/ folder, dartdocs, or README to get a basic understanding of the library's function.


import 'dart:io';

import 'package:easy_tui/cli/io/out/terminal_out.dart';
import 'package:easy_tui/tui/menu_modifiers.dart';
import 'package:easy_tui/tui/text_form_ui.dart';
import 'package:easy_tui/tui/text_option_ui.dart';

void main()
//	Create the UI class 
	final TextOptionUI main = new TextOptionUI(
///			The [modifier] parameter is a list of modifiers
/// 		In this case, `MenuModifiers.MAIN_MENU` is the modifier.
			modifiers: <MenuModifiers>{ MenuModifiers.MAIN_MENU }

/// Add content to a `TextUI` through the [lines] property
		/* 1 */ "Say hello",
		/* 2 */ "Go to a submenu",
		/* 3 */ "Enter some data",
		/* 4 */ "Exit"

/// `TextUI`s with the `MenuModifiers.MAIN_MENU` property __should loop__
	while ( true )
///		`switch` statements are a good way to handle [present]'s return value
		switch ( main.present() ) 
			case 1:
				print("\nHello, user!\n");
			case 2:
						"I didn't feel like demoing this, " 
						"but you can put as many menus into menus as your feel like."
			case 3:
				final TextFormUI dataEntry = new TextFormUI();
				const String queryName = "name?";
				const String queryAge  = "age?";
				const String queryDOB  = "date of birth?";

///				[present()] has an  __optional named parameter__ 
///				that prepends the questions with the `String` provided.
/// 			So, the questions would be "_What is your_ name?", 
/// 			"_What is your_ age?", and "_What is your_ date of birth"?
				final Map<String, String> answers = dataEntry.present(prepend: "What is your ");
						"\nYour name is: ${answers[queryName]}, "
						"\nYour age is: ${answers[queryAge]}, " 
						"\nYour DOB is: ${answers[queryDOB]}"
			case 4:
		TerminalOut.enterToClear("Returning to main menu...");

Use this package as a library

1. Depend on it

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

  easy_tui: ^3.3.0

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:easy_tui/cli/io/in/terminal_input.dart';
import 'package:easy_tui/cli/io/out/terminal_out.dart';
import 'package:easy_tui/tui.dart';
import 'package:easy_tui/tui/layouts.dart';
import 'package:easy_tui/tui/menu_modifiers.dart';
import 'package:easy_tui/tui/text_dialogue.dart';
import 'package:easy_tui/tui/text_form_ui.dart';
import 'package:easy_tui/tui/text_option_ui.dart';
import 'package:easy_tui/tui/text_ui.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

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

  • Dart: 2.7.1
  • pana: 0.13.6

Health suggestions

Fix lib/tui/text_form_ui.dart. (-1.99 points)

Analysis of lib/tui/text_form_ui.dart reported 4 hints:

line 55 col 40: Unnecessary new keyword.

line 122 col 5: Unnecessary new keyword.

line 126 col 36: Unnecessary new keyword.

line 160 col 39: Unnecessary new keyword.

Fix lib/tui/text_ui.dart. (-1.49 points)

Analysis of lib/tui/text_ui.dart reported 3 hints:

line 32 col 17: Unnecessary new keyword.

line 68 col 28: Unnecessary new keyword.

line 92 col 36: Unnecessary new keyword.

Fix lib/tui/text_option_ui.dart. (-1 points)

Analysis of lib/tui/text_option_ui.dart reported 2 hints:

line 96 col 12: Unnecessary new keyword.

line 122 col 28: Unnecessary new keyword.

Fix additional 5 files with analysis or formatting issues.

Additional issues in the following files:

  • lib/cli/io/in/terminal_input.dart (Run dartfmt to format lib/cli/io/in/terminal_input.dart.)
  • lib/cli/io/out/terminal_out.dart (Run dartfmt to format lib/cli/io/out/terminal_out.dart.)
  • lib/tui/layouts.dart (Run dartfmt to format lib/tui/layouts.dart.)
  • lib/tui/menu_modifiers.dart (Run dartfmt to format lib/tui/menu_modifiers.dart.)
  • lib/tui/text_dialogue.dart (Run dartfmt to format lib/tui/text_dialogue.dart.)

Maintenance issues and suggestions

Homepage URL isn't helpful. (-10 points)

Update the homepage field from pubspec.yaml: link to a website about the package or use the source repository URL.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.3.0 <3.0.0
meta ^1.1.7 1.1.8
Dev dependencies
pedantic ^1.0.0