/* require() plugin which returns a handle to the repo Db object for
   Fossil.require's shared Fossil.Context. If no repo has been opened
   when this is called, it opens the repo specified via the
   --repo-db|-R=FILENAME CLI script flag, failing if that flag is
   not available. */
return requireS2(['fsl/context','cliargs'], proc(F,args){
  if(!F.hasDb('repo')){
    const f = args.takeFlag('repo-db',args.takeFlag('R'))
          ||| throw "No repo db specified. "+
          "Pass the --repo-db|-R=filename "+
          "SCRIPT flag (after --) to the interpreter or open a checkout.";
    ('string' === typename f) || throw "Invalid argument type for the --repo-db|-R=DBFILE flag";
    F.openRepo(f);
  }
  return F.db;
});
