How to make root file parse arguments from command line?

Hello,

As someone who has been learning both C++ and ROOT at the same time, one of the issues I am having trouble with is figuring out how to implement a way to parse arguments from the command line into my main function. Currently, I have my main function where I want to open a ROOT file, it looks like this

int main(int argc, char* argv[]) {

  //Parse arguments

  std::unique_ptr<TFile> myFile{TFile::Open(filename, "UPDATE")};


  //TFile full(fileName);
  fileIterator(myFile);
  return 0;
  //RNTupleMover();

I would like a way to input a root file from the command line and get its name. Thank you!
ROOT Version: 6.34.04
Platform: Windows
Compiler: Not Provided


Hi Oswaldo,

This question is important but not really related to ROOT.
You can access the arguments at the command line as elements of the argv array, i.e. argv[0], argv[1], …
First hit on a popular web search engine: link

Cheers,
D

I recommend GitHub - CLIUtils/CLI11: CLI11 is a command line parser for C++11 and beyond that provides a rich feature set with a simple and intuitive interface.

It’s header-only, so no need to do much extra compilation.