From 10d6035e141a6840e262afad0d669bf173d88ed0 Mon Sep 17 00:00:00 2001 From: Herbert Poul Date: Sun, 7 Mar 2021 23:30:13 +0000 Subject: [PATCH] remove dependency on prompts. --- bin/kdbx.dart | 19 ++++++++++++++++--- pubspec.yaml | 1 - 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/bin/kdbx.dart b/bin/kdbx.dart index 38dd488..402e6e4 100644 --- a/bin/kdbx.dart +++ b/bin/kdbx.dart @@ -10,7 +10,6 @@ import 'package:kdbx/src/kdbx_format.dart'; import 'package:kdbx/src/utils/print_utils.dart'; import 'package:logging/logging.dart'; import 'package:logging_appenders/logging_appenders.dart'; -import 'package:prompts/prompts.dart' as prompts; final _logger = Logger('kdbx'); @@ -83,8 +82,7 @@ abstract class KdbxFileCommand extends Command { } final bytes = await File(inputFile).readAsBytes(); final password = argResults['password'] as String ?? - prompts.get('Password for $inputFile', - conceal: true, validate: (str) => str.isNotEmpty); + _readPassword('Password for $inputFile: '); final keyFile = argResults['keyfile'] as String; final keyFileData = keyFile == null ? null : await File(keyFile).readAsBytes(); @@ -100,6 +98,21 @@ abstract class KdbxFileCommand extends Command { Future runWithFile(KdbxFile file); } +String _readPassword(String prompt) { + try { + stdin.echoMode = false; + stdout.write(prompt); + while (true) { + final input = stdin.readLineSync(); + if (input.isNotEmpty) { + return input; + } + } + } finally { + stdin.echoMode = true; + } +} + class CatCommand extends KdbxFileCommand { CatCommand() { argParser.addFlag('decrypt', diff --git a/pubspec.yaml b/pubspec.yaml index 49d1e9f..a1a210b 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -29,7 +29,6 @@ dependencies: # required for bin/ args: '>1.5.0 <3.0.0' - prompts: '>=1.3.0 <2.0.0' logging_appenders: '>=0.1.0 <2.0.0' argon2_ffi_base: ^1.0.0