Skip to content

Commit

Permalink
Add -v option to show version
Browse files Browse the repository at this point in the history
  • Loading branch information
embetrix committed Dec 27, 2024
1 parent 4edbdd1 commit 7995b7b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions bmap-writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,24 +342,30 @@ int BmapWriteImage(const std::string &imageFile, const bmap_t &bmap, const std::

static void printUsage(const char *progname) {
std::cerr << "Usage: " << progname << " "
<< "[-hn] <image-file> <bmap-file> <target-device>" << std::endl;
<< "[-hvn] <image-file> <bmap-file> <target-device>" << std::endl;
std::cerr << std::endl;
std::cerr << "-n : Skip checksum verification" << std::endl;
std::cerr << "-v : Show version" << std::endl;
std::cerr << "-h : Show this help and exit" << std::endl;
}

int main(int argc, char *argv[]) {
bool noVerify = false;
int opt;

while ((opt = getopt(argc, argv, "hn")) != -1) {
while ((opt = getopt(argc, argv, "hnv")) != -1) {
switch (opt) {
case 'n':
noVerify = true;
break;
case 'h':
printUsage(argv[0]);
return 0;
case 'v':
if (std::strlen(GIT_VERSION) > 0) {
std::cout << "Version: " << GIT_VERSION << std::endl;
}
return 0;
default:
std::cerr << "Unknown option -" << static_cast<char>(opt) << std::endl;
printUsage(argv[0]);
Expand Down

0 comments on commit 7995b7b

Please sign in to comment.