|
|
@ -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', |
|
|
|