diff --git a/usb_manager/bin/usb_manager.dart b/usb_manager/bin/usb_manager.dart index 22097ba..d6cf11d 100644 --- a/usb_manager/bin/usb_manager.dart +++ b/usb_manager/bin/usb_manager.dart @@ -1,30 +1,27 @@ import 'dart:async' show unawaited; import 'dart:io' show exit; -import 'package:console/console.dart' show Chooser; +import 'package:cli_menu/cli_menu.dart' show Menu; import 'package:fpdart/fpdart.dart' show IO; -import 'package:usb_manager/usb_manager.dart'; - import 'package:zerothreesix_dart/zerothreesix_dart.dart'; +import 'package:usb_manager/usb_manager.dart'; + void _menu() { cyan(lang(11)); IO( - Chooser( - [lang(13), lang(14), lang(15), lang(16)], - message: lang(12), - ).chooseSync, - ).map((final sel) { - if (sel == lang(13)) { + Menu([lang(13), lang(14), lang(15), lang(16)]).choose, + ).map((final op) { + if (op.value == lang(13)) { clear(); unawaited(usblistener(Action.mount, _menu)); - } else if (sel == lang(14)) { + } else if (op.value == lang(14)) { clear(); unawaited(usblistener(Action.unmount, _menu)); - } else if (sel == lang(15)) { + } else if (op.value == lang(15)) { clear(); unawaited(usblistener(Action.off, _menu)); - } else if (sel == lang(16)) { + } else if (op.value == lang(16)) { clear(); exit(0); } diff --git a/usb_manager/lib/usblistener.dart b/usb_manager/lib/usblistener.dart index 4665fee..53daf45 100644 --- a/usb_manager/lib/usblistener.dart +++ b/usb_manager/lib/usblistener.dart @@ -1,6 +1,6 @@ import 'dart:io' show stdin; -import 'package:console/console.dart' show Chooser; +import 'package:cli_menu/cli_menu.dart' show Menu; import 'package:fpdart/fpdart.dart' show IO; import 'package:zerothreesix_dart/zerothreesix_dart.dart'; @@ -96,12 +96,9 @@ Future usblistener( spinAction.cancel(); IO( - Chooser( - action == Action.off ? argspoweroff : args, - message: lang(12), - ).chooseSync, - ).map((final sel) { - if (sel == lang(25)) { + Menu(action == Action.off ? argspoweroff : args).choose, + ).map((final op) { + if (op.value == lang(25)) { clear(); call(); return; @@ -109,11 +106,11 @@ Future usblistener( clear(); switch (action) { case Action.mount: - usbAction(sel, true, call); + usbAction(op.value, true, call); case Action.unmount: - usbAction(sel, false, call); + usbAction(op.value, false, call); case Action.off: - powerOff(sel, call); + powerOff(op.value, call); } } }).run(); diff --git a/usb_manager/pubspec.lock b/usb_manager/pubspec.lock index 1ccbebe..aba0ed0 100644 --- a/usb_manager/pubspec.lock +++ b/usb_manager/pubspec.lock @@ -10,7 +10,7 @@ packages: source: hosted version: "1.3.0" cli_menu: - dependency: transitive + dependency: "direct main" description: name: cli_menu sha256: "8e2ad533d6fa657bf944d943b948862f2c0cfcf1fa6568be9b65eef5573394bf" @@ -34,7 +34,7 @@ packages: source: hosted version: "1.1.1" console: - dependency: "direct main" + dependency: transitive description: name: console sha256: e04e7824384c5b39389acdd6dc7d33f3efe6b232f6f16d7626f194f6a01ad69a diff --git a/usb_manager/pubspec.yaml b/usb_manager/pubspec.yaml index 51ac74c..42d133d 100644 --- a/usb_manager/pubspec.yaml +++ b/usb_manager/pubspec.yaml @@ -6,7 +6,7 @@ environment: sdk: '>=3.3.2 <4.0.0' dependencies: - console: ^4.1.0 + cli_menu: ^0.4.0+1 fpdart: ^1.1.0 zerothreesix_dart: ^0.1.3