Skip to content

Commit

Permalink
"error handling" and version bump
Browse files Browse the repository at this point in the history
  • Loading branch information
codeshaunted committed May 4, 2024
1 parent d2458a5 commit c1eeee8
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 12 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
*.app

# Visual Studio
.vscode/
.vs/
CMakeSettings.json

Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# codeshaunted - monke
# CMakeLists.txt
# root CMake file
# Copyright 2022 codeshaunted
# Copyright 2024 codeshaunted
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -17,7 +17,7 @@

cmake_minimum_required(VERSION 3.12)

project(monke VERSION 1.2)
project(monke VERSION 1.3)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
Expand Down
4 changes: 2 additions & 2 deletions include/monke/pack.hh
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ namespace monke {

class Pack {
public:
static void unpack(std::string_view __input_path, std::string_view __output_path, std::string_view __password);
static void pack(std::string_view __input_path, std::string_view __output_path, std::string_view __password);
static void unpack(std::string_view input_path, std::string_view output_path, std::string_view password);
static void pack(std::string_view input_path, std::string_view output_path, std::string_view password);
};

} // namespace monke
Expand Down
24 changes: 16 additions & 8 deletions source/monke/main.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// codeshaunted - monke
// source/monke/main.cc
// contains entry point
// Copyright 2022 codeshaunted
// Copyright 2024 codeshaunted
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -23,7 +23,7 @@

void help() {
std::cout << "monke v" << MONKE_VERSION_MAJOR << "." << MONKE_VERSION_MINOR << std::endl;
std::cout << "Copyright 2021 codeshaunted" << std::endl << std::endl;
std::cout << "Copyright 2024 codeshaunted" << std::endl << std::endl;
std::cout << "Usage: monke <command> [arguments]" << std::endl << std::endl;
std::cout << "Commands:" << std::endl;
std::cout << " pack <input path> <output path> <password>" << std::endl;
Expand All @@ -42,19 +42,27 @@ int main(int argc, char* argv[]) {
return 0;
}

monke::Pack::unpack(argv[2], argv[3], argv[4]);

std::cout << "Unpacked '" << argv[2] << "' with password '" << argv[4] << "' to '" << argv[3] << "'." << std::endl;
// cursed error handling
// at least it doesn't silent fail anymore ¯\_(ツ)_/¯
try {
monke::Pack::unpack(argv[2], argv[3], argv[4]);
std::cout << "Unpacked '" << argv[2] << "' with password '" << argv[4] << "' to '" << argv[3] << "'." << std::endl;
} catch (...) {
std::cout << "Failed to unpack '" << argv[2] << "' with password '" << argv[4] << "!" << std::endl;
}
}
else if (!strcmp(argv[1], "pack") || !strcmp(argv[1], "p")) {
if (argc != 5) {
help();
return 0;
}

monke::Pack::pack(argv[2], argv[3], argv[4]);

std::cout << "Packed '" << argv[2] << "' with password '" << argv[4] << "' to '" << argv[3] << "'." << std::endl;
try {
monke::Pack::pack(argv[2], argv[3], argv[4]);
std::cout << "Packed '" << argv[2] << "' with password '" << argv[4] << "' to '" << argv[3] << "'." << std::endl;
} catch (...) {
std::cout << "Failed to pack '" << argv[2] << "' with password '" << argv[4] << "!" << std::endl;
}
}
else {
help();
Expand Down

0 comments on commit c1eeee8

Please sign in to comment.