Enhance command-line interface with cxxopts for argument parsing and add playful responses
This commit is contained in:
parent
0bf90124f1
commit
fe42bd43bf
7
debian/changelog
vendored
7
debian/changelog
vendored
@ -1,12 +1,11 @@
|
|||||||
jigsaw (0.1-3) bookworm; urgency=medium
|
jigsaw (0.1-3) bookworm; urgency=medium
|
||||||
|
|
||||||
* Added console line argument parsing
|
* Added command-line argument parsing using cxxopts
|
||||||
* Added a dummy menu
|
* Implemented --help, --version, --play, and --sphageti options with basic responses
|
||||||
* Added a help menu
|
* Added a simple help menu and playful output for no arguments
|
||||||
|
|
||||||
-- Jack <contact@chipperfluff.at> Tue, 02 Jul 2025 15:10:00 +0200
|
-- Jack <contact@chipperfluff.at> Tue, 02 Jul 2025 15:10:00 +0200
|
||||||
|
|
||||||
|
|
||||||
jigsaw (0.1-2) bookworm; urgency=medium
|
jigsaw (0.1-2) bookworm; urgency=medium
|
||||||
|
|
||||||
* Made it executable
|
* Made it executable
|
||||||
|
|||||||
36
src/main.cpp
36
src/main.cpp
@ -2,29 +2,49 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include "../includes/cxxopts/include/cxxopts.hpp"
|
#include "../includes/cxxopts/include/cxxopts.hpp"
|
||||||
|
|
||||||
|
#define VERSION_STRING "0.1.3"
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
try {
|
try {
|
||||||
cxxopts::Options options("jigsaw", "CLI horror filler program");
|
cxxopts::Options options("jigsaw", "This is a test APT repo. Maybe a game later.");
|
||||||
|
|
||||||
options.add_options()
|
options.add_options()
|
||||||
("h,help", "Show help")
|
("h,help", "Show this help message")
|
||||||
("p,play", "Play the game");
|
("v,version", "Show version")
|
||||||
|
("p,play", "Get a SANS response")
|
||||||
|
("s,sphageti", "Summon Papyrus");
|
||||||
|
|
||||||
auto result = options.parse(argc, argv);
|
auto result = options.parse(argc, argv);
|
||||||
|
|
||||||
if (result.count("help")) {
|
if (result.count("help")) {
|
||||||
std::cout << options.help() << std::endl;
|
std::cout << options.help() << "\n";
|
||||||
|
std::cout << "Hint: This tool is part of a test APT repo — maybe it becomes a game later 👀\n";
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result.count("version")) {
|
||||||
|
std::cout << "jigsaw version " << VERSION_STRING << "\n";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result.count("play")) {
|
if (result.count("play")) {
|
||||||
std::cout << "Initiating game sequence... (placeholder)\n";
|
std::cout << "SANS: heya. you're gonna have a bad time if you keep doing that.\n";
|
||||||
} else {
|
return 0;
|
||||||
std::cout << "Hello. I am a filler. And I want to play a game.\n";
|
}
|
||||||
|
|
||||||
|
if (result.count("sphageti")) {
|
||||||
|
std::cout << "PAPYRUS: NYEH HEH HEH!! SPAGHETTI FOR ALL!!\n";
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// No arguments provided
|
||||||
|
if (result.arguments().empty()) {
|
||||||
|
std::cout << "hahahah u thought somethign hapsn here?\n";
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
std::cerr << "Error parsing options: " << e.what() << std::endl;
|
std::cerr << "Error parsing options: " << e.what() << "\n";
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user