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