mason icon indicating copy to clipboard operation
mason copied to clipboard

feat: Add `link` ansi wrapper

Open Luckey-Elijah opened this issue 1 year ago • 0 comments

Description

Add an ANSI wrapper that enables hyperlinks/links in the terminal. More info at this Gist on how to achieve the desired effect.

I've done this in one of my projects, but I think it might server others as well.

Requirements

  • [ ] API to "wrap" a string with a link for stdout.

Additional Context

An example API:

Future<void> main() async {
  Logger(level: Level.verbose).info(
    linkWrap(
      'You can find issues here',
      'https://github.com/felangel/mason/issues/',
    ),
  );
}
String linkWrap(String message, String link) {
  final uri = '\x1B]8;;$link\x1B\\';
  final text = '$message\x1B]8;;\x1B\\';
  return '$uri$text';
}
hyperlink

Luckey-Elijah avatar Jul 18 '22 18:07 Luckey-Elijah