2
0
mirror of https://github.com/vasi/pixz synced 2024-10-30 15:21:41 +00:00

Merge pull request #101 from teran/add-version-flag

Add -V flag to print application version
This commit is contained in:
Dave Vasilevsky 2022-01-23 00:54:47 -05:00 committed by GitHub
commit 1eb74e8ee8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -44,6 +44,7 @@ static void usage(const char *msg) {
" -t Don't assume input is in tar format\n" " -t Don't assume input is in tar format\n"
" -k Keep original input (do not remove it)\n" " -k Keep original input (do not remove it)\n"
" -c ignored\n" " -c ignored\n"
" -V Print version and exit\n"
" -h Print this help\n" " -h Print this help\n"
"\n" "\n"
"pixz %s\n" "pixz %s\n"
@ -56,6 +57,11 @@ static void usage(const char *msg) {
exit(0); exit(0);
} }
static void version() {
fprintf(stderr, "pixz %s\n", PACKAGE_VERSION);
exit(0);
}
int main(int argc, char **argv) { int main(int argc, char **argv) {
uint32_t level = LZMA_PRESET_DEFAULT; uint32_t level = LZMA_PRESET_DEFAULT;
bool tar = true; bool tar = true;
@ -80,6 +86,7 @@ int main(int argc, char **argv) {
case 'k': keep_input = true; break; case 'k': keep_input = true; break;
case 'h': usage(NULL); break; case 'h': usage(NULL); break;
case 'e': extreme = true; break; case 'e': extreme = true; break;
case 'V': version(); break;
case 'f': case 'f':
optdbl = strtod(optarg, &optend); optdbl = strtod(optarg, &optend);
if (*optend || optdbl <= 0) if (*optend || optdbl <= 0)