Browse Source

remove dependency on prompts.

null-safety
Herbert Poul 4 years ago
parent
commit
10d6035e14
  1. 19
      bin/kdbx.dart
  2. 1
      pubspec.yaml

19
bin/kdbx.dart

@ -10,7 +10,6 @@ import 'package:kdbx/src/kdbx_format.dart';
import 'package:kdbx/src/utils/print_utils.dart'; import 'package:kdbx/src/utils/print_utils.dart';
import 'package:logging/logging.dart'; import 'package:logging/logging.dart';
import 'package:logging_appenders/logging_appenders.dart'; import 'package:logging_appenders/logging_appenders.dart';
import 'package:prompts/prompts.dart' as prompts;
final _logger = Logger('kdbx'); final _logger = Logger('kdbx');
@ -83,8 +82,7 @@ abstract class KdbxFileCommand extends Command<void> {
} }
final bytes = await File(inputFile).readAsBytes(); final bytes = await File(inputFile).readAsBytes();
final password = argResults['password'] as String ?? final password = argResults['password'] as String ??
prompts.get('Password for $inputFile', _readPassword('Password for $inputFile: ');
conceal: true, validate: (str) => str.isNotEmpty);
final keyFile = argResults['keyfile'] as String; final keyFile = argResults['keyfile'] as String;
final keyFileData = final keyFileData =
keyFile == null ? null : await File(keyFile).readAsBytes(); keyFile == null ? null : await File(keyFile).readAsBytes();
@ -100,6 +98,21 @@ abstract class KdbxFileCommand extends Command<void> {
Future<void> runWithFile(KdbxFile file); Future<void> 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 { class CatCommand extends KdbxFileCommand {
CatCommand() { CatCommand() {
argParser.addFlag('decrypt', argParser.addFlag('decrypt',

1
pubspec.yaml

@ -29,7 +29,6 @@ dependencies:
# required for bin/ # required for bin/
args: '>1.5.0 <3.0.0' args: '>1.5.0 <3.0.0'
prompts: '>=1.3.0 <2.0.0'
logging_appenders: '>=0.1.0 <2.0.0' logging_appenders: '>=0.1.0 <2.0.0'
argon2_ffi_base: ^1.0.0 argon2_ffi_base: ^1.0.0

Loading…
Cancel
Save