add print version flag
This commit is contained in:
parent
53c4f40cfa
commit
918dea1056
2 changed files with 37 additions and 1 deletions
|
@ -11,6 +11,7 @@ void print_help(const char *argv0)
|
|||
"\n\t-w: display WIDTH bytes per column"
|
||||
"\n\t-e: display some extended info(*) (may slow down the startup)"
|
||||
"\n\t-n: list the names of the RNTuples found in the file and exit"
|
||||
"\n\t-v: print version and copyright info"
|
||||
"\n"
|
||||
"\nNOTES:"
|
||||
"\n- if `ntuple_name' is not passed, rntviewer will look for the first RNTuple in the TFile."
|
||||
|
@ -20,9 +21,38 @@ void print_help(const char *argv0)
|
|||
, argv0);
|
||||
}
|
||||
|
||||
internal
|
||||
void print_version_and_copyright()
|
||||
{
|
||||
printf(
|
||||
"\n-----------------------------------------------------------------------------"
|
||||
"\n rntviewer v" V_MAJOR "." V_MINOR
|
||||
"\n"
|
||||
"\n A graphical interactive RNTuple visualizer"
|
||||
"\n-----------------------------------------------------------------------------"
|
||||
"\n"
|
||||
"\nCopyright (C) 2024 silverweed"
|
||||
"\n"
|
||||
"\nThis program is free software: you can redistribute it and/or modify it"
|
||||
"\nunder the terms of the GNU General Public License as published by the "
|
||||
"\nFree Software Foundation, either version 3 of the License, or (at your option)"
|
||||
"\nany later version."
|
||||
"\n"
|
||||
"\nThis program is distributed in the hope that it will be useful, but"
|
||||
"\nWITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY"
|
||||
"\nor FITNESS FOR A PARTICULAR PURPOSE."
|
||||
"\nSee the GNU General Public License for more details."
|
||||
"\n"
|
||||
"\nYou should have received a copy of the GNU General Public License along"
|
||||
"\nwith this program. If not, see <https://www.gnu.org/licenses/>."
|
||||
"\n\n"
|
||||
);
|
||||
}
|
||||
|
||||
struct Cmdline_Args {
|
||||
b8 print_to_terminal;
|
||||
b8 show_help_and_exit;
|
||||
b8 show_version_and_exit;
|
||||
u64 start_addr;
|
||||
u64 nbytes_displayed;
|
||||
u16 n_cols;
|
||||
|
@ -116,6 +146,8 @@ Cmdline_Args parse_args(i32 argc, char **argv)
|
|||
parse_int_arg(i, argc, argv, args.nbytes_displayed);
|
||||
else if (arg[1] == 'n')
|
||||
args.only_print_rntuple_names = true;
|
||||
else if (arg[1] == 'v')
|
||||
args.show_version_and_exit = true;
|
||||
else if (arg[1] == 'w') {
|
||||
u64 n_cols = 0;
|
||||
parse_int_arg(i, argc, argv, n_cols);
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
//
|
||||
// rntviewer
|
||||
//
|
||||
// A graphical RNTuple visualizer
|
||||
// A graphical interactive RNTuple visualizer
|
||||
//
|
||||
// @author silverweed, 2024
|
||||
//
|
||||
|
@ -124,6 +124,10 @@ int main(int argc, char **argv)
|
|||
|
||||
// Parse cmdline
|
||||
Cmdline_Args args = parse_args(argc, argv);
|
||||
if (args.show_version_and_exit) {
|
||||
print_version_and_copyright();
|
||||
return 0;
|
||||
}
|
||||
if (args.show_help_and_exit || !args.file_name.size) {
|
||||
print_help(argv[0]);
|
||||
return 1;
|
||||
|
|
Loading…
Add table
Reference in a new issue