MlirOptMain call the function multiple times

Hello,

I want to call MlirOptMain function(llvm-project/mlir/lib/Support/MlirOptMain.cpp) multiple times for different files. But I can’t call the function more than once because the command line options are created and initialized only once.

  static cl::opt<std::string> inputFilename(
      cl::Positional, cl::desc("<input file>"), cl::init("-"));

  static cl::opt<std::string> outputFilename("o", cl::desc("Output filename"),
                                             cl::value_desc("filename"),
                                             cl::init("-"));

How can I run MlirOptMain function multiple times?

The options will be registered once, but the parsing happens on each invocation isn’t it? https://github.com/llvm/llvm-project/blob/main/mlir/lib/Support/MlirOptMain.cpp#L220