27static const char *
const kShortHelp =
"usage: rootbrowse [-w WEB|-wf] <file.root>\n";
29Open a ROOT file in a TBrowser
35 -h, --help show this help message and exit
36 -w, --web WEB Configure webdisplay. For all possible values, see TROOT::SetWebDisplay():
37 https://root.cern/doc/latest-stable/classTROOT.html#a1749472696545b76a6b8e79769e7e773
38 -wf, --webOff Invoke the classic TBrowser (not the web version)
45 Open the ROOT file 'file.root' in a TBrowser
65 opts.
AddFlag({
"-wf",
"--webOff"});
67 opts.
Parse(args, nArgs);
93int main(
int argc,
char **argv)
97 auto args =
ParseArgs(
const_cast<const char **
>(argv) + 1, argc - 1);
109 TRint app(
"rootbrowse",
nullptr,
nullptr);
111 if (!args.fWeb.empty())
112 gROOT->SetWebDisplay(std::string(args.fWeb).c_str());
114 std::unique_ptr<TFile>
file;
115 if (!args.fFileName.empty()) {
117 file = std::unique_ptr<TFile>(
TFile::Open(std::string(args.fFileName).c_str(),
"READ"));
119 Err() <<
"File " << args.fFileName <<
" does not exist or is unreadable.\n";
125 auto browser = std::make_unique<TBrowser>();
127 if (
gROOT->IsBatch())
131 if (
auto imp = browser->GetBrowserImp()) {
132 if (
auto mainframe = imp->GetMainFrame()) {
133 mainframe->Connect(
"CloseWindow()",
"TRint", &app,
"Terminate()");
137 std::cout <<
".q to exit.\n";
138 while (!
gROOT->IsInterrupted() && !
gSystem->ProcessEvents()) {
139 std::this_thread::sleep_for(std::chrono::milliseconds(10));
externInt_t gErrorIgnoreLevel
errors with level below this value will be ignored. Default is kUnset.
void AddFlag(std::initializer_list< std::string_view > aliases, EFlagType type=EFlagType::kSwitch, std::string_view help="", std::uint32_t flagOpts=0)
Defines a new flag (either a switch or a flag with argument).
int GetSwitch(std::string_view name) const
If name refers to a previously-defined switch (i.e.
const std::vector< std::string > & GetArgs() const
Retrieves all positional arguments.
std::string_view GetFlagValue(std::string_view name) const
If name refers to a previously-defined non-switch flag, gets its value.
void Parse(const char **args, std::size_t nArgs)
bool ReportErrors(std::ostream &stream=std::cerr) const
Conveniency method to print any errors to stream.
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
Create / open a file.
void InitLog(const char *name, int defaultVerbosity=1)
static const char *const kShortHelp
Command line tool to open a ROOT file on a TBrowser.
static RootBrowseArgs ParseArgs(const char **args, int nArgs)
static const char *const kLongHelp