Add option to print version from cli

presentation
idotobi 6 years ago committed by Fabian Keßler
parent ba327c7bdc
commit 3346402940
  1. 8
      src/control/XournalMain.cpp

@ -267,16 +267,19 @@ auto XournalMain::run(int argc, char* argv[]) -> int {
gchar** optFilename = nullptr;
gchar* pdfFilename = nullptr;
gchar* imgFilename = nullptr;
gboolean showVersion = false;
int openAtPageNumber = -1;
string create_pdf = _("PDF output filename");
string create_img = _("Image output filename (.png / .svg)");
string page_jump = _("Jump to Page (first Page: 1)");
string audio_folder = _("Absolute path for the audio files playback");
string version = _("Get version of xournalpp");
GOptionEntry options[] = {{"create-pdf", 'p', 0, G_OPTION_ARG_FILENAME, &pdfFilename, create_pdf.c_str(), nullptr},
{"create-img", 'i', 0, G_OPTION_ARG_FILENAME, &imgFilename, create_img.c_str(), nullptr},
{"page", 'n', 0, G_OPTION_ARG_INT, &openAtPageNumber, page_jump.c_str(), "N"},
{G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &optFilename, "<input>", nullptr},
{"version", 0, 0, G_OPTION_ARG_NONE, &showVersion, version.c_str(), nullptr},
{nullptr}};
g_option_context_add_main_entries(context, options, GETTEXT_PACKAGE);
@ -299,6 +302,11 @@ auto XournalMain::run(int argc, char* argv[]) -> int {
return exportImg(*optFilename, imgFilename);
}
if (showVersion) {
g_printf("%s %s \n", PROJECT_NAME, PROJECT_VERSION);
return 0;
}
// Checks for input method compatibility
const char* imModule = g_getenv("GTK_IM_MODULE");

Loading…
Cancel
Save