easy_tui 3.3.0

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.

example/main.dart

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
	main.lines.addAll(<String>[
		/* 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");
				break;
			case 2:
				TerminalOut.enterToContinue(
						"I didn't feel like demoing this, " 
						"but you can put as many menus into menus as your feel like."
					);
				break;
			case 3:
				final TextFormUI dataEntry = new TextFormUI();
				const String queryName = "name?";
				const String queryAge  = "age?";
				const String queryDOB  = "date of birth?";
				dataEntry.lines.addAll(<String>[
					queryName,
					queryAge,
					queryDOB
				]);

///				[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 ");
				print(
						"\nYour name is: ${answers[queryName]}, "
						"\nYour age is: ${answers[queryAge]}, " 
						"\nYour DOB is: ${answers[queryDOB]}"
					);
				break;
			case 4:
				exit(0);
				break;
		}
		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:


dependencies:
  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';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
16
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
80
Overall:
Weighted score of the above. [more]
54
Learn more about scoring.

We analyzed this package on Sep 10, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.5.0
  • pana: 0.12.21

Platforms

Detected platforms: Flutter, other

Platform components identified in package: io.

Health suggestions

Format lib/cli/io/in/terminal_input.dart.

Run dartfmt to format lib/cli/io/in/terminal_input.dart.

Format lib/cli/io/out/terminal_out.dart.

Run dartfmt to format lib/cli/io/out/terminal_out.dart.

Format lib/tui/layouts.dart.

Run dartfmt to format lib/tui/layouts.dart.

Fix additional 5 files with analysis or formatting issues.

Additional issues in the following files:

  • 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.)
  • lib/tui/text_form_ui.dart (Run dartfmt to format lib/tui/text_form_ui.dart.)
  • lib/tui/text_option_ui.dart (Run dartfmt to format lib/tui/text_option_ui.dart.)
  • lib/tui/text_ui.dart (Run dartfmt to format lib/tui/text_ui.dart.)

Maintenance issues and suggestions

Homepage URL doesn't exist. (-20 points)

At the time of the analysis the homepage field https://pub.dev/packages/easy_tui was unreachable.

Dependencies

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