test: Update 4 files
Some checks failed
Build-Test-Publish / build (linux/arm64) (push) Failing after 13s
Build-Test-Publish / build (linux/amd64) (push) Failing after 31s
Build-Test-Publish / test-install-from-scratch (linux/amd64) (push) Has been skipped
Build-Test-Publish / test-install-from-scratch (linux/arm64) (push) Has been skipped
Some checks failed
Build-Test-Publish / build (linux/arm64) (push) Failing after 13s
Build-Test-Publish / build (linux/amd64) (push) Failing after 31s
Build-Test-Publish / test-install-from-scratch (linux/amd64) (push) Has been skipped
Build-Test-Publish / test-install-from-scratch (linux/arm64) (push) Has been skipped
This commit is contained in:
parent
a12270f6c2
commit
6ed73ef5a8
@ -4,6 +4,7 @@
|
|||||||
struct Args {
|
struct Args {
|
||||||
bool silent = false;
|
bool silent = false;
|
||||||
bool update = false;
|
bool update = false;
|
||||||
|
bool version = false;
|
||||||
std::string source;
|
std::string source;
|
||||||
std::string dest;
|
std::string dest;
|
||||||
};
|
};
|
||||||
|
@ -10,28 +10,39 @@ Usage: dehydrate [OPTIONS] SOURCE DEST
|
|||||||
Options:
|
Options:
|
||||||
-s Silent mode (no output)
|
-s Silent mode (no output)
|
||||||
-u Update dehydrate to the latest version
|
-u Update dehydrate to the latest version
|
||||||
|
-v Show version only
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
dehydrate file.txt output/ Creates _file.txt.cpp and _file.txt.hpp in output/
|
dehydrate file.txt output/ Creates _file.txt.cpp and _file.txt.hpp in output/
|
||||||
dehydrate src/ output/ Creates _src.cpp and _src.hpp in output/
|
dehydrate src/ output/ Creates _src.cpp and _src.hpp in output/
|
||||||
dehydrate -u Updates dehydrate to the latest version
|
dehydrate -u Updates dehydrate to the latest version
|
||||||
|
dehydrate -v Shows version number
|
||||||
)";
|
)";
|
||||||
|
|
||||||
Args parse_args(int argc, char* argv[]) {
|
Args parse_args(int argc, char* argv[]) {
|
||||||
Args args;
|
Args args;
|
||||||
int idx = 1;
|
int idx = 1;
|
||||||
|
|
||||||
// Check for silent flag
|
// Parse flags
|
||||||
if (idx < argc && std::string(argv[idx]) == "-s") {
|
while (idx < argc && argv[idx][0] == '-') {
|
||||||
args.silent = true;
|
std::string flag = argv[idx];
|
||||||
|
|
||||||
|
if (flag == "-s") {
|
||||||
|
args.silent = true;
|
||||||
|
} else if (flag == "-u") {
|
||||||
|
args.update = true;
|
||||||
|
} else if (flag == "-v") {
|
||||||
|
args.version = true;
|
||||||
|
} else {
|
||||||
|
throw std::runtime_error("Unknown flag: " + flag + "\n\n" + HELP_TEXT);
|
||||||
|
}
|
||||||
|
|
||||||
idx++;
|
idx++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for update flag
|
// If update or version flag is set, return early
|
||||||
if (idx < argc && std::string(argv[idx]) == "-u") {
|
if (args.update || args.version) {
|
||||||
args.update = true;
|
return args;
|
||||||
idx++;
|
|
||||||
return args; // No need for source and dest parameters when updating
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Require source and dest parameters for normal operation
|
// Require source and dest parameters for normal operation
|
||||||
|
@ -57,14 +57,23 @@ int update()
|
|||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
try {
|
try {
|
||||||
std::cout << "Dehydrate version " << VERSION << std::endl;
|
|
||||||
Args args = parse_args(argc, argv);
|
Args args = parse_args(argc, argv);
|
||||||
|
|
||||||
|
// Handle version request (output only version)
|
||||||
|
if (args.version) {
|
||||||
|
std::cout << VERSION << std::endl;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
// Handle update request
|
// Handle update request
|
||||||
if (args.update) {
|
if (args.update) {
|
||||||
|
std::cout << "Dehydrate version " << VERSION << std::endl;
|
||||||
return update();
|
return update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Show version for normal operations
|
||||||
|
std::cout << "Dehydrate version " << VERSION << std::endl;
|
||||||
|
|
||||||
std::filesystem::path src(args.source);
|
std::filesystem::path src(args.source);
|
||||||
if (!std::filesystem::exists(src)) {
|
if (!std::filesystem::exists(src)) {
|
||||||
std::cerr << "Source does not exist: " << args.source << std::endl;
|
std::cerr << "Source does not exist: " << args.source << std::endl;
|
||||||
|
@ -59,11 +59,11 @@ fi
|
|||||||
|
|
||||||
echo "Using dehydrate binary: $DEHYDRATE"
|
echo "Using dehydrate binary: $DEHYDRATE"
|
||||||
|
|
||||||
# Test 1: Version command (dehydrate shows version in help output)
|
# Test 1: Version command (dehydrate -v shows version only)
|
||||||
echo "Test 1: Version command"
|
echo "Test 1: Version command"
|
||||||
VERSION_OUTPUT=$("$DEHYDRATE" 2>&1 || true)
|
VERSION_OUTPUT=$("$DEHYDRATE" -v 2>&1 || true)
|
||||||
# Extract version from the beginning of help output
|
# Version output should be just the version number
|
||||||
VERSION=$(echo "$VERSION_OUTPUT" | head -n 1 | sed 's/Dehydrate version //')
|
VERSION=$(echo "$VERSION_OUTPUT" | head -n 1)
|
||||||
if [[ "$VERSION" =~ ^[0-9]{4}\.[0-9]{4}\.[0-9]{4}$ ]]; then
|
if [[ "$VERSION" =~ ^[0-9]{4}\.[0-9]{4}\.[0-9]{4}$ ]]; then
|
||||||
print_test_result "Version format (YYYY.MMDD.HHMM)" 0
|
print_test_result "Version format (YYYY.MMDD.HHMM)" 0
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user