Example #1
0
File: F_Add.cs Project: jcr6/NJCR
 public override void Run(FlagParse fp)
 {
     if (fp.Args.Length == 1 || fp.GetBool("h"))
     {
         QCol.Green("Add files to a JCR file! Available switches are:\n\n");
         QCol.Yellow("-doj             "); QCol.Cyan("Destroy original JCR file, so begin completely fresh, always\n");
         QCol.Yellow("-i               "); QCol.Cyan("Input file(s) or directory/directories. (deprecated)\n");
         QCol.Yellow("-cm <method>     "); QCol.Cyan("Compression method for the files inside the JCR file (default is lzma)\n");
         QCol.Yellow("-fc <method>     "); QCol.Cyan("Compression method for the file table inside the JCR file (default is lzma)\n");
         QCol.Yellow("-jif <file>      "); QCol.Cyan("Read a JCR Instruction File to see how files must be stored and under which conditions\n");
         QCol.Yellow("-author <author> "); QCol.Cyan("Add an author to the files added (jif files ignore this flag)\n");
         QCol.Yellow("-notes <notes>   "); QCol.Cyan("Add notes to the files added (jif files ignore this flag)\n");
         QCol.Yellow("-nomerge         "); QCol.Cyan("When set, files detected as JCR6 compatible files will not be merged, but just be addd as a regular file!\n");
         QCol.Yellow("-puremerge       "); QCol.Cyan("When set, entries being added due to JCR-merging will not be repacked, but be directly copied\n");
         QCol.Yellow("                 "); QCol.Magenta("It goes without saying, but using -nomerge and -puremerge in one run is not a very clever thing to do.");
         //QCol.Yellow("-qu              "); QCol.Cyan("Quick update. (Type \"NJCR quhelp\" for more information)\n");
         QCol.Blue("\n\n\n");
         QCol.Green("JCR6 supports the next compression methods:\n");
         foreach (string name in JCR6.CompDrivers.Keys)
         {
             QCol.Red("\t* "); QCol.Yellow($"{name}\n");
         }
         return;
     }
     quick   = fp.GetBool("qu");
     jcrfile = fp.Args[1];
     toadd   = Files(fp);
     filetablecompression = fp.GetString("fc");
     compressionmethod    = fp.GetString("cm");
     puremerge            = fp.GetBool("puremerge");
     nomerge = fp.GetBool("nomerge");
     if (fp.GetString("i") != "")
     {
         var l = new List <string>(toadd);
         l.Add(fp.GetString("i"));
         toadd = l.ToArray();
     }
     updating = File.Exists(jcrfile) && !fp.GetBool("doj");
     if (toadd.Length == 0)
     {
         Add2List(Directory.GetCurrentDirectory(), "", compressionmethod, fp.GetString("author"), fp.GetString("notes"));
     }
     else
     {
         foreach (string fil in toadd)
         {
             Add2List(fil, qstr.StripDir(fil), compressionmethod, fp.GetString("author"), fp.GetString("notes"));
         }
     }
     if (fp.GetString("jif") != "")
     {
         ParseJIF(fp.GetString("jif"));
     }
     if (updating)
     {
         QCol.Doing("Updating", jcrfile);
     }
     else
     {
         QCol.Doing("Creating", jcrfile);
     }
     QCol.Doing("File Storage", compressionmethod);
     QCol.Doing("Table Storage", filetablecompression);
     QCol.Doing("No merge", $"{nomerge}");
     QCol.Doing("Pure merge", $"{puremerge}");
     QCol.Doing("Files", $"{Jiffy.Count}");
     QCol.Doing("NJCR", MKL.MyExe);
     QCol.Doing("PWD", Directory.GetCurrentDirectory());
     Console.WriteLine("\n\n");
     Go();
 }