From 1cb1966342cc6d93790d7c5a9649397c8d032993 Mon Sep 17 00:00:00 2001 From: murat Date: Sat, 31 Jan 2026 16:20:32 +0300 Subject: [PATCH] created main.cpp checking for --help and -h flags checking for arg count checking if specified file exists --- main.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 main.cpp diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..41c8ab8 --- /dev/null +++ b/main.cpp @@ -0,0 +1,30 @@ +#include +#include +#include +using std::cout; +namespace fs = std::filesystem; + +int main(int argc, char *argv[]) { + for (int i = 0; i <= argc - 1; i++) { + std::string arg = argv[i]; + if (arg == "--help" || arg == "-h") { + cout << "help flag detected!"; + return 0; + } + } + + if (argc != 2) { + cout << "Please specify image file. " << argv[0] << " imagefile.jpg"; + } else { + std::string imagefile = argv[1]; + cout << "File: " << imagefile << "\n"; + + if (!fs::is_regular_file(imagefile)) { + std::cout << "File not found: " << imagefile << "\n"; + return 1; + } + } + + return 0; +} +