fzyzcjy / dart_interactive

REPL (interactive shell) for Dart, supporting 3rd party packages, hot reload, and full grammar
https://github.com/fzyzcjy/dart_interactive
MIT License
147 stars 12 forks source link

Provide a convenient way to exit #52

Closed Quijx closed 1 year ago

Quijx commented 1 year ago

Is your feature request related to a problem? Please describe. It would be nice to have a convenient built-in way to exit the repl. Entering import 'dart:io'; and then exit(0) is not really that convenient. (Also it seems to do some weird stuff with the shell, for example i can't see any further input after the program terminates but that is likely a different issue.) The shourtcuts Ctrl+C (send sig TERM) or Ctrl+D (EOF) work but other repls have things like exit() aswell, so I think it would be nice to have too.

Describe the solution you'd like For example global getter Never get quit => exit(0); could be defined in a file that is imported by default that in turn imports dart:io.

Describe alternatives you've considered Or it could be a function Never quit() => exit(0).

fzyzcjy commented 1 year ago

Totally agree.

For example global getter Never get quit => exit(0); could be defined in a file that is imported by default that in turn imports dart:io.

Just put in https://github.com/fzyzcjy/dart_interactive/blob/master/packages/interactive/lib/src/runtime_support.dart#L1