Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9d91ec912a | |||
| 7e431d98e9 | |||
| 90ffb25a2b |
43
build.sh
43
build.sh
@@ -16,18 +16,31 @@ print_error() { echo -e "${RED}[ERROR]${NC} $1"; }
|
|||||||
# Global variable for commit message
|
# Global variable for commit message
|
||||||
COMMIT_MESSAGE=""
|
COMMIT_MESSAGE=""
|
||||||
|
|
||||||
# Parse command line arguments for -m flag
|
# Parse command line arguments - check if first arg is a command, otherwise treat as commit message
|
||||||
while [[ $# -gt 0 ]]; do
|
COMMAND=""
|
||||||
case $1 in
|
if [[ $# -gt 0 ]]; then
|
||||||
-m|--message)
|
case "$1" in
|
||||||
COMMIT_MESSAGE="$2"
|
build|clean|install|uninstall)
|
||||||
shift 2
|
COMMAND="$1"
|
||||||
|
shift
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
# Keep other arguments for main logic
|
# First argument is not a command, so default to build and treat all args as commit message
|
||||||
break
|
COMMAND="build"
|
||||||
;;
|
;;
|
||||||
esac
|
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
|
done
|
||||||
|
|
||||||
# Function to automatically increment version
|
# Function to automatically increment version
|
||||||
@@ -321,7 +334,7 @@ uninstall_project() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Main script logic
|
# Main script logic
|
||||||
case "${1:-build}" in
|
case "$COMMAND" in
|
||||||
build)
|
build)
|
||||||
build_project
|
build_project
|
||||||
;;
|
;;
|
||||||
@@ -336,10 +349,11 @@ case "${1:-build}" in
|
|||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "OTP Cipher Build Script"
|
echo "OTP Cipher Build Script"
|
||||||
echo "Usage: $0 [-m \"commit message\"] {build|clean|install|uninstall}"
|
echo "Usage: $0 [command] [commit message]"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Options:"
|
echo "Arguments:"
|
||||||
echo " -m, --message \"text\" - Specify commit message (skips interactive prompt)"
|
echo " command - {build|clean|install|uninstall} (default: build)"
|
||||||
|
echo " commit message - Text to use as commit message (optional, skips interactive prompt)"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Commands:"
|
echo "Commands:"
|
||||||
echo " build - Cross-compile for x86_64 and ARM64/AArch64 with automatic version increment (default)"
|
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 ""
|
||||||
echo "Examples:"
|
echo "Examples:"
|
||||||
echo " $0"
|
echo " $0"
|
||||||
echo " $0 -m \"Fixed checksum parsing bug\""
|
echo " $0 \"Fixed checksum parsing bug\""
|
||||||
echo " $0 --message \"Added new feature\" build"
|
echo " $0 build \"Added new feature\""
|
||||||
|
echo " $0 clean"
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|||||||
23
src/main.c
23
src/main.c
@@ -24,8 +24,9 @@ int main(int argc, char* argv[]) {
|
|||||||
// Load preferences
|
// Load preferences
|
||||||
load_preferences();
|
load_preferences();
|
||||||
|
|
||||||
// Detect interactive mode: only true when running with no arguments
|
// Detect interactive mode: true when running with no arguments AND no piped input
|
||||||
set_interactive_mode((argc == 1));
|
int is_interactive = (argc == 1 && !has_stdin_data());
|
||||||
|
set_interactive_mode(is_interactive);
|
||||||
|
|
||||||
// Check for OTP thumb drive on startup
|
// Check for OTP thumb drive on startup
|
||||||
char otp_drive_path[512];
|
char otp_drive_path[512];
|
||||||
@@ -46,15 +47,25 @@ int main(int argc, char* argv[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int command_line_mode(int argc, char* argv[]) {
|
int command_line_mode(int argc, char* argv[]) {
|
||||||
// Check for help flags first
|
// Check for help flags first (only if we have arguments)
|
||||||
if (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--h") == 0 ||
|
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 ||
|
||||||
strcmp(argv[1], "help") == 0) {
|
strcmp(argv[1], "help") == 0)) {
|
||||||
print_usage(argv[0]);
|
print_usage(argv[0]);
|
||||||
return 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) {
|
if (argc != 3) {
|
||||||
printf("Usage: %s generate|-g <size>\n", argv[0]);
|
printf("Usage: %s generate|-g <size>\n", argv[0]);
|
||||||
printf("Size examples: 1024, 1GB, 5TB, 512MB\n");
|
printf("Size examples: 1024, 1GB, 5TB, 512MB\n");
|
||||||
|
|||||||
@@ -193,8 +193,10 @@ int generate_pad(uint64_t size_bytes, int display_progress) {
|
|||||||
printf("Pad file set to read-only\n");
|
printf("Pad file set to read-only\n");
|
||||||
printf("Use 'Add entropy' in Pads menu to enhance randomness.\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)
|
||||||
print_centered_header("Pad Generation Complete", 1);
|
if (get_interactive_mode()) {
|
||||||
|
print_centered_header("Pad Generation Complete", 1);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user