๐Ÿ› ๏ธ promptr

A simple and extensible Dart package for building interactive command-line interfaces.

promptr makes it easy to gather input from users with clean prompts and multiple input typesโ€”text, numbers, confirmations, and even menu-style options. Perfect for robust CLI tools and scripts.


โœจ Features

  • Prompt for single-line or multi-line text input
  • Default value support
  • Yes/no confirmations
  • Integer input with validation
  • Single or multiple choice menus
  • ANSI color support

๐Ÿš€ Getting Started

๐Ÿ“ฆ Installation

Add promptr to your pubspec.yaml:

dependencies:
  promptr: ^1.0.0

Then run:

dart pub get

๐Ÿงช Example

import 'package:io/ansi.dart';
import 'package:promptr/promptr.dart' as promptr;

/// Example: Developer Profile Setup CLI using `promptr`.
void main() {
  print('๐Ÿ‘จโ€๐Ÿ’ป Welcome to Developer Profile Setup!\n');

  // Prompt for the developer's username
  final username = promptr.get('Choose a username');
  print('Nice to meet you, @$username!');

  // Ask for a short bio with multiline support
  final bio = promptr.get(
    'Write a short bio (use \\ to escape line breaks):',
    allowMultiline: true,
    inputColor: cyan,
  );
  print('\nBio saved!');

  // Ask for primary programming language
  final languages = ['Dart', 'Python', 'JavaScript', 'C++', 'Go'];
  final primaryLang = promptr.choose(
    'Pick your primary programming language:',
    languages,
    defaultsTo: 'Dart',
  );
  print('Primary language set to: $primaryLang');

  // Ask for years of experience with integer validation
  final experience = promptr.getInt(
    'How many years of coding experience do you have?',
    defaultsTo: 2,
  );
  print('Great! $experience years of experience logged.');

  // Ask for technologies familiar with (multi-select)
  final techStack = ['Flutter', 'Node.js', 'Firebase', 'Docker', 'Kubernetes'];
  final knownTech = promptr.multiChoose(
    'Select all technologies youโ€™ve worked with:',
    techStack,
  );
  print('Your tech stack: ${knownTech.join(', ')}');

  // Confirm if they want to save this profile
  final shouldSave = promptr.getBool('Do you want to save your profile?');
  if (shouldSave) {
    print(green.wrap('\nโœ… Profile saved successfully!'));
  } else {
    print(red.wrap('\nโŒ Profile not saved.'));
  }
}


๐Ÿ“š API Overview

Method Description
promptr.get(...) Prompt for user input (supports multiline)
promptr.getBool(...) Yes/No confirmation
promptr.getInt(...) Prompt for an integer with optional default
promptr.choose(...) Multi-line, user-friendly choice menu
promptr.chooseShorthand(...) Quick one-liner style menu
promptr.multiChoose(...) Select multiple options from a list

๐Ÿ“ธ Demo Project

MasterHead

Check out this dart package built using promptr:
๐Ÿ‘‰ flutter_starter_x on pub.dev


๐Ÿงฉ Contributions

Got a new prompt idea? Open a PR or issue!


๐Ÿ“œ License

MIT ยฉ 2025 \Mohammed Shibil M


Libraries

promptr