Skip to main content

gg_interact 0.0.1 copy "gg_interact: ^0.0.1" to clipboard
gg_interact: ^0.0.1 copied to clipboard

Interactive terminal prompts for the gg suite - select, input and confirm, with headless detection.

gg_interact #

Interactive terminal prompts for the gg suite: select, input and confirm, with headless detection.

import 'package:gg_interact/gg_interact.dart';

throwWhenNotATerminal('the name prompt', 'pass --name');

final prompts = GgPrompts.current;
final index = await prompts.select(prompt: 'Language', options: ['Dart', 'TS']);
final name = await prompts.inputUntilValid(
  prompt: 'Name',
  validate: (v) => v.isEmpty ? 'Please enter a name.' : null,
  onInvalid: print,
);
final ok = await prompts.confirm(prompt: 'Create $name?');
  • GgPrompts.current is what every gg prompt goes through. An embedder without a terminal — gg in Node, say — answers by assigning it; tests assign a scripted subclass and reset it with GgPrompts.current = null.
  • select and input are the two prompts an embedder implements. confirm and inputUntilValid are built on them.
  • throwWhenNotATerminal fails fast in CI, pipes and scripts instead of waiting forever for an answer.
  • A Wasm build has no dart:ffi; its prompts throw GgPromptsUnsupportedError until an embedder supplies some.

The prompts used to live in gg_one_core, which re-exports them unchanged.

0
likes
0
points
108
downloads

Publisher

verified publisherinlavigo.com

Weekly Downloads

Interactive terminal prompts for the gg suite - select, input and confirm, with headless detection.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

gg_console_colors, interact

More

Packages that depend on gg_interact