123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105(**************************************************************************)(* *)(* Copyright 2020 OCamlPro & Origin Labs *)(* *)(* All rights reserved. This file is distributed under the terms of the *)(* GNU Lesser General Public License version 2.1, with the special *)(* exception on linking described in the file LICENSE. *)(* *)(**************************************************************************)openTypesopenEzcmd.V2openEZCMD.TYPESopenUpdateopenEz_file.V1openEzFile.OPletcmd_name="project"(* lookup for "drom.toml" and update it *)letaction~skeleton~edit~args=beginmatchProject.lookup()with|None->Error.raise"No project found. Maybe you need to create a project first with 'drom \
new PROJECT'"|Some(dir,_)->ifeditthenleteditor=Misc.editor()inmatchPrintf.kprintfSys.command"%s '%s'"editor(dir//"drom.toml")with|0->()|_->Error.raise"Editing command returned a non-zero status"end;letproject=Project.find()inmatchprojectwith|None->assertfalse|Some(p,_)->let_sk=Skeleton.lookup_projectskeletoninletargs={argswitharg_upgrade=(ifp.skeleton<>skeletonthenbeginp.skeleton<-skeleton;trueendelseargs.arg_upgrade)}inUpdate.update_files~twice:false~args~create:false~git:truepletcmd=letskeleton=refNoneinletargs,specs=Update.update_args()inletedit=reffalseinEZCMD.subcmd_name(fun()->action~skeleton:!skeleton~edit:!edit~args)~args:(specs@[(["library"],Arg.Unit(fun()->skeleton:=Some"library";args.arg_upgrade<-true),EZCMD.info"Project contains only a library. Equivalent to $(b,--skeleton library)");(["program"],Arg.Unit(fun()->skeleton:=Some"program";args.arg_upgrade<-true),EZCMD.info"Project contains a program. Equivalent to $(b,--skeleton program). The generated project will be composed of a $(i,library) package and a $(i,driver) package calling the $(b,Main.main) of the library.");(["virtual"],Arg.Unit(fun()->skeleton:=Some"virtual";args.arg_upgrade<-true),EZCMD.info"Package is virtual, i.e. no code. Equivalent to $(b,--skeleton virtual).");(["skeleton"],Arg.String(funs->skeleton:=Somes;args.arg_upgrade<-true),EZCMD.info~docv:"SKELETON""Create project using a predefined skeleton or one specified in \
~/.config/drom/skeletons/");(["upgrade"],Arg.Unit(fun()->args.arg_upgrade<-true),EZCMD.info"Force upgrade of the drom.toml file from the skeleton");(["edit"],Arg.Setedit,EZCMD.info"Edit project description");])~doc:"Update an existing project"~man:[`S"DESCRIPTION";`Blocks[`P"This command is used to regenerate the files of a project after updating its description.";`P"With argument $(b,--upgrade), it can also be used to reformat the toml files, from their skeletons.";];]