Compare commits

...

2 Commits

5 changed files with 50 additions and 22 deletions

View File

@@ -16,18 +16,31 @@ print_error() { echo -e "${RED}[ERROR]${NC} $1"; }
# Global variable for commit message
COMMIT_MESSAGE=""
# Parse command line arguments for -m flag
while [[ $# -gt 0 ]]; do
case $1 in
-m|--message)
COMMIT_MESSAGE="$2"
shift 2
# Parse command line arguments - check if first arg is a command, otherwise treat as commit message
COMMAND=""
if [[ $# -gt 0 ]]; then
case "$1" in
build|clean|install|uninstall)
COMMAND="$1"
shift
;;
*)
# Keep other arguments for main logic
break
# First argument is not a command, so default to build and treat all args as commit message
COMMAND="build"
;;
esac
else
# No arguments, default to build
COMMAND="build"
fi
# Any remaining arguments become the commit message
for arg in "$@"; do
if [[ -z "$COMMIT_MESSAGE" ]]; then
COMMIT_MESSAGE="$arg"
else
COMMIT_MESSAGE="$COMMIT_MESSAGE $arg"
fi
done
# Function to automatically increment version
@@ -321,7 +334,7 @@ uninstall_project() {
}
# Main script logic
case "${1:-build}" in
case "$COMMAND" in
build)
build_project
;;
@@ -336,10 +349,11 @@ case "${1:-build}" in
;;
*)
echo "OTP Cipher Build Script"
echo "Usage: $0 [-m \"commit message\"] {build|clean|install|uninstall}"
echo "Usage: $0 [command] [commit message]"
echo ""
echo "Options:"
echo " -m, --message \"text\" - Specify commit message (skips interactive prompt)"
echo "Arguments:"
echo " command - {build|clean|install|uninstall} (default: build)"
echo " commit message - Text to use as commit message (optional, skips interactive prompt)"
echo ""
echo "Commands:"
echo " build - Cross-compile for x86_64 and ARM64/AArch64 with automatic version increment (default)"
@@ -357,8 +371,9 @@ case "${1:-build}" in
echo ""
echo "Examples:"
echo " $0"
echo " $0 -m \"Fixed checksum parsing bug\""
echo " $0 --message \"Added new feature\" build"
echo " $0 \"Fixed checksum parsing bug\""
echo " $0 build \"Added new feature\""
echo " $0 clean"
exit 1
;;
esac

BIN
otp-arm64 Executable file

Binary file not shown.

BIN
otp-x86_64 Executable file

Binary file not shown.

View File

@@ -24,8 +24,9 @@ int main(int argc, char* argv[]) {
// Load preferences
load_preferences();
// Detect interactive mode: only true when running with no arguments
set_interactive_mode((argc == 1));
// Detect interactive mode: true when running with no arguments AND no piped input
int is_interactive = (argc == 1 && !has_stdin_data());
set_interactive_mode(is_interactive);
// Check for OTP thumb drive on startup
char otp_drive_path[512];
@@ -46,15 +47,25 @@ int main(int argc, char* argv[]) {
}
int command_line_mode(int argc, char* argv[]) {
// Check for help flags first
if (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--h") == 0 ||
// Check for help flags first (only if we have arguments)
if (argc > 1 && (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--h") == 0 ||
strcmp(argv[1], "-help") == 0 || strcmp(argv[1], "--help") == 0 ||
strcmp(argv[1], "help") == 0) {
strcmp(argv[1], "help") == 0)) {
print_usage(argv[0]);
return 0;
}
if (strcmp(argv[1], "generate") == 0 || strcmp(argv[1], "-g") == 0) {
// If no arguments but piped input, default to encrypt mode
if (argc == 1 && has_stdin_data()) {
char* piped_text = read_stdin_text();
if (piped_text) {
int result = pipe_mode(argc, argv, piped_text);
free(piped_text);
return result;
}
}
if (argc > 1 && (strcmp(argv[1], "generate") == 0 || strcmp(argv[1], "-g") == 0)) {
if (argc != 3) {
printf("Usage: %s generate|-g <size>\n", argv[0]);
printf("Size examples: 1024, 1GB, 5TB, 512MB\n");

View File

@@ -193,8 +193,10 @@ int generate_pad(uint64_t size_bytes, int display_progress) {
printf("Pad file set to read-only\n");
printf("Use 'Add entropy' in Pads menu to enhance randomness.\n");
// Pause before returning to menu to let user see the success message
// Pause before returning to menu to let user see the success message (only in interactive mode)
if (get_interactive_mode()) {
print_centered_header("Pad Generation Complete", 1);
}
return 0;
}