示例#1
0
        public static int Main(string[] args)
        {
            var root = new RootCommand(typeof(Program).Assembly.GetCustomAttribute <AssemblyTitleAttribute> ().Title);

            root.AddLicenseOption();


            var cmdPak = new Command("pak", "Process PAK files");

            root.Add(cmdPak);

            var cmdPakList = new Command("list", "List contents of a PAK file")
            {
                IsHidden = true
            };

            cmdPakList.AddArgument(new Argument <FileInfo> ("source", "Path to the PAK file").ExistingOnly());
            cmdPakList.AddOption(new Option <LocalHeaderField[]> ("--local-header")
            {
                IsHidden = true
            });                                                                                                           //uglifies help output
            cmdPakList.AddOption(new Option("--sort"));
            cmdPakList.Handler = CommandHandler.Create <FileInfo, LocalHeaderField[], bool> (DoPakList);
            cmdPak.Add(cmdPakList);

            var cmdPakPack = new Command("pack", "Pack contents of a directory into a single PAK file");

            cmdPakPack.AddArgument(new Argument <DirectoryInfo> ("source", "Path to the directory containing files").ExistingOnly());
            cmdPakPack.AddArgument(new Argument <FileInfo> ("target", "Path to a PAK file that will be created").NonExistingOnly());
            cmdPakPack.AddOption(new Option("--mixed-cache-block", "Indicates the source directory contains mixed contents of initial.pak and initial.pak\\initial.cache_block"));
            cmdPakPack.Handler = CommandHandler.Create <DirectoryInfo, FileInfo, bool> (DoPakPack);
            cmdPak.Add(cmdPakPack);


            var cmdCacheBlock = new Command("cache_block", "Process cache_block files");

            cmdCacheBlock.AddAlias("cb");
            root.Add(cmdCacheBlock);

            var cmdCacheBlockList = new Command("list", "List contents of a cache_block file");

            cmdCacheBlockList.AddArgument(new Argument <FileInfo> ("source", "Path to the cache_block file").ExistingOnly());
            cmdCacheBlockList.Handler = CommandHandler.Create <FileInfo> (DoCacheBlockList);
            cmdCacheBlock.Add(cmdCacheBlockList);

            var cmdCacheBlockUnpack             = new Command("unpack", "Unpack contents of a cache_block file into a directory");
            var cmdCacheBlockUnpack_AllowMixing = new Option("--allow-mixing", "Allow mixing of contents for initial.pak and initial.pak\\initial.cache_block");

            cmdCacheBlockUnpack.AddArgument(new Argument <FileInfo> ("source", "Path to the cache_block file").ExistingOnly());
            cmdCacheBlockUnpack.AddArgument(new Argument <DirectoryInfo> ("target", "Path to a directory that will be created to unpack into").NonExistingOnly(unless: cmdCacheBlockUnpack_AllowMixing));
            cmdCacheBlockUnpack.AddOption(cmdCacheBlockUnpack_AllowMixing);
            cmdCacheBlockUnpack.Handler = CommandHandler.Create <FileInfo, DirectoryInfo, bool> (DoCacheBlockUnpack);
            cmdCacheBlock.Add(cmdCacheBlockUnpack);

            var cmdCacheBlockPack = new Command("pack", "Pack contents of a directory into a single cache_block file");

            cmdCacheBlockPack.AddArgument(new Argument <DirectoryInfo> ("source", "Path to the directory containing files").ExistingOnly());
            cmdCacheBlockPack.AddArgument(new Argument <FileInfo> ("target", "Path to a cache_block file that will be created").NonExistingOnly());
            cmdCacheBlockPack.AddOption(new Option("--mixed-cache-block", "Indicates the source directory contains mixed contents of initial.pak and initial.pak\\initial.cache_block"));
            cmdCacheBlockPack.Handler = CommandHandler.Create <DirectoryInfo, FileInfo, bool> (DoCacheBlockPack);
            cmdCacheBlock.Add(cmdCacheBlockPack);


            var cmdLoadList = new Command("load_list", "Process load_list files");

            cmdLoadList.AddAlias("ll");
            root.Add(cmdLoadList);

            var cmdLoadListList = new Command("list", "List contents of a load_list file");

            cmdLoadListList.AddOption(new Option("--compact", "Use compact format (internal names only)"));
            cmdLoadListList.AddArgument(new Argument <FileInfo> ("source", "Path to the load_list file").ExistingOnly());
            cmdLoadListList.Handler = CommandHandler.Create <FileInfo, bool> (DoLoadListList);
            cmdLoadList.Add(cmdLoadListList);

            var cmdLoadListCreate = new Command("create-initial", "Create load_list file using conventions for initial.pak\\pak.load_list");

            cmdLoadListCreate.AddAlias("ci");
            cmdLoadListCreate.AddArgument(new Argument <FileInfo> ("target", "Path to a load_list file that will be created").NonExistingOnly());
            cmdLoadListCreate.AddArgument(new Argument <FileSystemInfo> ("initial", "Path to the initial.pak file or a directory with its contents").ExistingOnly());
            cmdLoadListCreate.AddArgument(new Argument <FileSystemInfo> ("shared", "Path to the shared.pak file or a directory with its contents").ExistingOnly());
            cmdLoadListCreate.AddArgument(new Argument <FileSystemInfo> ("shared_sound", "Path to the shared_sound.pak file or a directory with its contents").ExistingOnly());
            cmdLoadListCreate.Handler = CommandHandler.Create <FileInfo, FileSystemInfo, FileSystemInfo, FileSystemInfo> (DoLoadListCreate);
            cmdLoadList.Add(cmdLoadListCreate);


            var cmdSoundList = new Command("sound_list", "Process sound_list files");

            cmdSoundList.AddAlias("sl");
            root.Add(cmdSoundList);

            var cmdSoundListList = new Command("list", "List contents of a sound_list file");

            cmdSoundListList.AddArgument(new Argument <FileInfo> ("source", "Path to the sound_list file").ExistingOnly());
            cmdSoundListList.Handler = CommandHandler.Create <FileInfo> (DoSoundListList);
            cmdSoundList.Add(cmdSoundListList);

            var cmdSoundListCreate = new Command("create", "Create sound_list file");

            cmdSoundListCreate.AddArgument(new Argument <FileSystemInfo> ("source", "Path to the PAK file or a directory containing PCM files").ExistingOnly());
            cmdSoundListCreate.AddArgument(new Argument <FileInfo> ("target", "Path to the sound_list file").NonExistingOnly());
            cmdSoundListCreate.Handler = CommandHandler.Create <FileSystemInfo, FileInfo> (DoSoundListCreate);
            cmdSoundList.Add(cmdSoundListCreate);

            return(root.InvokeWithMiddleware(args, CommandLineExtensions.MakePrintLicenseResourceMiddleware(typeof(Program))));
        }
示例#2
0
        /*
         *      truck CustomizationCameras --FOV:40 "D:\Games\SnowRunner_backs\mods\.staging\initial-pak\[media]\classes\trucks\ank_mk38.xml"
         */

        public static int Main(string[] args)
        {
            var root = new RootCommand(typeof(Program).Assembly.GetCustomAttribute <AssemblyTitleAttribute> ().Title);

            root.AddLicenseOption();


            var cmdTruck = new Command("truck", "Trucks configuration");

            root.Add(cmdTruck);

            var cmdTruckCustomizationCameras = new Command("CustomizationCameras");

            cmdTruckCustomizationCameras.AddOption(new Option <float?> ("--FOV"));
            cmdTruckCustomizationCameras.AddOption(new Option <float?> ("--MaxZoom"));
            var targetXmlWildcardsArgument = new Argument <IEnumerable <FileInfo> > ("targetXmls", CommandLineExtensions.ParseWildcards)
            {
                Description = "Truck XML file to modify (wildcards supported)"
            }.ExistingOrWildcardOnly();

            cmdTruckCustomizationCameras.AddArgument(targetXmlWildcardsArgument);
            cmdTruckCustomizationCameras.Handler = CommandHandler.Create <IEnumerable <FileInfo>, float?, float?> (DoTruckCustomizationCameras);
            cmdTruck.Add(cmdTruckCustomizationCameras);


            var cmdTruckCraneSocket = new Command("CraneSocket");

            cmdTruck.Add(cmdTruckCraneSocket);

            var cmdTruckCraneSocketAdd = new Command("add");

            cmdTruckCraneSocket.Add(cmdTruckCraneSocketAdd);

            var cmdTruckCraneSocketAddTopCentral = new Command("top-central");
            var targetXmlArgument = new Argument <FileInfo> ("targetXml").ExistingOnly();

            cmdTruckCraneSocketAddTopCentral.AddArgument(targetXmlArgument);
            cmdTruckCraneSocketAddTopCentral.Handler = CommandHandler.Create <FileInfo> (DoTruckCraneSocketAddTopCentral);
            cmdTruckCraneSocketAdd.Add(cmdTruckCraneSocketAddTopCentral);


            var cmdTruckExtents = new Command("extents");

            cmdTruckExtents.AddArgument(targetXmlArgument);
            cmdTruckExtents.Handler = CommandHandler.Create <FileInfo> (DoTruckExtents);
            cmdTruck.Add(cmdTruckExtents);


            var cmdExtras = new Command("extras", "Extra configuration");

            root.Add(cmdExtras);

            var cmdExtrasRename = new Command("rename", "Rename game objects");

            cmdExtras.Add(cmdExtrasRename);

            var cmdExtrasRenameTires = new Command("tires", "Rename tires");
            var languageOption       = new Option <GameLanguage> ("--language")
            {
                Required = true
            };

            cmdExtrasRenameTires.AddOption(languageOption);
            var directoryArgument = new Argument <DirectoryInfo> ("directory", "Path to the directory with mixed contents of initial.pak and initial.pak\\initial.cache_block").ExistingOnly();

            cmdExtrasRenameTires.AddArgument(directoryArgument);
            cmdExtrasRenameTires.Handler = CommandHandler.Create <DirectoryInfo, GameLanguage> (ExtrasRenamer.RenameTires);
            cmdExtrasRename.Add(cmdExtrasRenameTires);

            var cmdExtrasRenameTrucks = new Command("trucks", "Rename trucks");

            cmdExtrasRenameTrucks.AddOption(languageOption);
            cmdExtrasRenameTrucks.AddArgument(directoryArgument);
            cmdExtrasRenameTrucks.Handler = CommandHandler.Create <DirectoryInfo, GameLanguage> (ExtrasRenamer.RenameTrucks);
            cmdExtrasRename.Add(cmdExtrasRenameTrucks);

            var cmdExtrasRenameEngines = new Command("engines", "Rename engines");

            cmdExtrasRenameEngines.AddOption(languageOption);
            cmdExtrasRenameEngines.AddArgument(directoryArgument);
            cmdExtrasRenameEngines.Handler = CommandHandler.Create <DirectoryInfo, GameLanguage> (ExtrasRenamer.RenameEngines);
            cmdExtrasRename.Add(cmdExtrasRenameEngines);

            return(root.InvokeWithMiddleware(args, CommandLineExtensions.MakePrintLicenseResourceMiddleware(typeof(Program))));
        }