feat: update age cli
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
package me.hatter.tools.tinyencrypt.config;
|
||||
|
||||
public class TinyEncryptConstant {
|
||||
public static final String VERSION = "0.6.3";
|
||||
public static final String VERSION = "0.6.4";
|
||||
|
||||
public static final String ENC_FILE_EXT = ".tinyenc";
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package me.hatter.tools.tinyencrypt.util;
|
||||
|
||||
import me.hatter.tools.commons.assertion.AssertUtil;
|
||||
import me.hatter.tools.commons.exception.JumpOutException;
|
||||
import me.hatter.tools.commons.io.RFile;
|
||||
import me.hatter.tools.commons.log.LogTool;
|
||||
import me.hatter.tools.commons.log.LogTools;
|
||||
@@ -25,13 +26,14 @@ public class AgeCliUtil {
|
||||
AssertUtil.isFalse(ageEnvelop.contains("'"), "Age-envelop cannot contains `'`");
|
||||
AssertUtil.isTrue(ageEnvelop.matches("^[\\-/+=\\n\\r\\sa-zA-Z0-9]+$"), "Age-envelop illegal");
|
||||
|
||||
final RFile recipientAgeFileWithoutSerial = RFile.fromUserHome(".tinyencrypt/" + ageRecipient + ".age");
|
||||
final RFile recipientAgeFileWithSerial = serialOpt.map(s -> RFile.fromUserHome(".tinyencrypt/" + ageRecipient + ".age." + s)).orElse(null);
|
||||
final RFile recipientAgeFile = serialOpt.map(s -> {
|
||||
final RFile recipientAgeFileWithSerial = RFile.fromUserHome(".tinyencrypt/" + ageRecipient + ".age." + s);
|
||||
return recipientAgeFileWithSerial.isFile() ? recipientAgeFileWithSerial : null;
|
||||
}).orElseGet(() -> RFile.fromUserHome(".tinyencrypt/" + ageRecipient + ".age"));
|
||||
|
||||
final RFile recipientAgeFile = ((recipientAgeFileWithSerial != null) && recipientAgeFileWithSerial.isFile())
|
||||
? recipientAgeFileWithSerial : recipientAgeFileWithoutSerial;
|
||||
|
||||
AssertUtil.isTrue(recipientAgeFile.isFile(), "Age key file required");
|
||||
if (!recipientAgeFile.isFile()) {
|
||||
throw new JumpOutException("Age key file required: " + recipientAgeFile.file().getAbsolutePath());
|
||||
}
|
||||
|
||||
final ProcessBuilder pb = new ProcessBuilder(
|
||||
"sh",
|
||||
|
||||
Reference in New Issue
Block a user