Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print version info on -v and --version #139

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/zopfli/zopfli.h
Expand Up @@ -27,6 +27,8 @@ Author: jyrki.alakuijala@gmail.com (Jyrki Alakuijala)
extern "C" {
#endif

#define ZOPFLI_VERSION "1.0.1"

/*
Options used throughout the program.
*/
Expand Down
15 changes: 14 additions & 1 deletion src/zopfli/zopfli_bin.c
Expand Up @@ -141,6 +141,10 @@ static char StringsEqual(const char* str1, const char* str2) {
return strcmp(str1, str2) == 0;
}

static void ShowVersion() {
fprintf(stderr, "zopfli version %s\n", ZOPFLI_VERSION);
}

int main(int argc, char* argv[]) {
ZopfliOptions options;
ZopfliFormat output_type = ZOPFLI_FORMAT_GZIP;
Expand Down Expand Up @@ -178,11 +182,20 @@ int main(int argc, char* argv[]) {
" --gzip output to gzip format (default)\n"
" --zlib output to zlib format instead of gzip\n"
" --deflate output to deflate format instead of gzip\n"
" --splitlast ignored, left for backwards compatibility\n");
" --splitlast ignored, left for backwards compatibility\n"
" --version show version and exit\n");
return 0;
}
else if (StringsEqual(arg, "--version")) {
ShowVersion();
return 0;
}
}

if (options.verbose) {
ShowVersion();
}

if (options.numiterations < 1) {
fprintf(stderr, "Error: must have 1 or more iterations\n");
return 0;
Expand Down