Exemplo n.º 1
0
        static void Main(string[] args)
        {
            var arguments = Cli.Parse <CliArguments>(args);

            if (!String.IsNullOrEmpty(arguments.SourceCodeDirectory))
            {
                var o = new Options();

                if (File.Exists(arguments.OptionsFile))
                {
                    o = JsonConvert.DeserializeObject <Options>(File.ReadAllText(arguments.OptionsFile));
                }
                else
                {
                    File.WriteAllText("BuildConf.json", JsonConvert.SerializeObject(o, Formatting.Indented));
                }

                var path = Path.GetFullPath(arguments.SourceCodeDirectory);

                if (!Directory.Exists(path))
                {
                    Console.WriteLine("Please provide src Directory");
                    return;
                }

                BuildSystemEngine.Compile(path, o);
            }
            else
            {
                Console.WriteLine("Please provide src Directory");
            }
        }
Exemplo n.º 2
0
        public void Pack(string[] args)
        {
            var c = Cli.Parse <PackCliArguments>(args);

            bool result;

            if (c.OutputFolder == null)
            {
                result = PboHandler.CreateAndWritePbo(new DirectoryInfo(c.InputFolder));
            }
            else
            {
                result = PboHandler.CreateAndWritePbo(new DirectoryInfo(c.InputFolder), new DirectoryInfo(c.OutputFolder));
            }

            if (result)
            {
                Console.WriteLine("PBO created");
                Environment.Exit(0);
            }
            else
            {
                Console.WriteLine("Failed to make PBO");
                Environment.Exit(1);
            }
        }
        public void Duplicates_HelpDoubles()
        {
            string[] args = new string[] { };

            Assert.Throws <InvalidModelException>(
                () => Cli.Parse <DuplicateHelpSingleModel>(args));
        }
Exemplo n.º 4
0
        public void Primary(string[] args)
        {
            var options = Cli.Parse <PrimaryCliCommandArgs>(args);
            var command = new PrimaryCliCommand();

            command.Handle(options);
        }
Exemplo n.º 5
0
            public void ShowRegions(string[] stringArgs)
            {
                var          args = Cli.Parse <RegionsCommand>(stringArgs);
                LinuxProcess proc;

                if (args.ProcessId != null)
                {
                    proc = new LinuxProcess(args.ProcessId.Value);
                }
                else if (args.ProcessName != null)
                {
                    proc = LinuxProcess.GetProcessesByName(args.ProcessName).Single();
                }
                else
                {
                    throw new Exception("Please pass a PID with -p");
                }

                Console.WriteLine($"Listing regions for PID {proc.Id}.");
                foreach (var region in proc.GetMemoryRegions())
                {
                    Console.WriteLine(region is LinuxMemoryRegion linuxReg && linuxReg.PathName != null
                        ? $"{region.Start:X}-{region.End:X} {region.PermissionString},\t{linuxReg.PathName} @{linuxReg.Offset:X}"
                        : $"{region.Start:X}-{region.End:X} {region.PermissionString}"
                                      );
                }
            }
Exemplo n.º 6
0
        static void Main(string[] args)
        {
            var arguments = Cli.Parse <AppSettings>(args);

            if (arguments.eKey != default &&
                arguments.GameId != default &&
                arguments.Region != default)
            {
                var replay = Replay.DownloadReplay(new GameKey()
                {
                    GameId = arguments.GameId, PlatformId = Enum.Parse <Region>(arguments.Region)
                }, arguments.eKey).GetAwaiter().GetResult();
                if (!string.IsNullOrEmpty(arguments.Output))
                {
                    replay.PackReplay(arguments.Output).GetAwaiter().GetResult();
                }
                else
                {
                    replay.PackReplay($"{arguments.Region}_{arguments.GameId}").GetAwaiter().GetResult();
                }
            }
            else
            {
                var downloader = new Downloader();
                downloader.Start().Wait();
            }
        }
Exemplo n.º 7
0
        static void Main(string[] args)
        {
            if (Cli.Parse <ApplicationSettings>(args).CliExitEarly)
            {
                return;
            }

            Directory.SetCurrentDirectory(Path.GetDirectoryName(Application.ExecutablePath));

            EnableLogging();

            Logger.Debug("Launched from {launchDirectory} with args {launchOptions}.", Directory.GetCurrentDirectory(), string.Join(" ", args));

            // Single instance handling
            _singleInstanceMutex = new Mutex(true, ApplicationSettings.Instance.MumbleMapName != null
                                                       ? $"{APP_GUID}:{ApplicationSettings.Instance.MumbleMapName}"
                                                       : $"{APP_GUID}");

            if (!_singleInstanceMutex.WaitOne(TimeSpan.Zero, true))
            {
                Logger.Warn("Blish HUD is already running!");
                return;
            }

            using (var game = new BlishHud()) {
                game.Run();
            }

            _singleInstanceMutex.ReleaseMutex();
        }
Exemplo n.º 8
0
        public void NotProvided()
        {
            string[] args = new string[] { };

            var model = Cli.Parse <OptionArgsModel>(args);

            Assert.StrictEqual(false, model.Option);
        }
Exemplo n.º 9
0
        public void OperandMap_Check0PositionValidation()
        {
            string[] args = new string[] {
            };

            Assert.Throws <InvalidModelException>(
                () => Cli.Parse <OperandStartAt0ArgsModel>(args));
        }
Exemplo n.º 10
0
        public void OperandMap_CheckContiguityValidation()
        {
            string[] args = new string[] {
            };

            Assert.Throws <InvalidModelException>(
                () => Cli.Parse <OperandNonContiguousArgsModel>(args));
        }
Exemplo n.º 11
0
        public void OperandMap_CheckDumpSize()
        {
            string[] args = new string[] { };

            var model = Cli.Parse <OperandArgsModel>(args);

            Assert.Equal(0, model.Operands.Length);
        }
Exemplo n.º 12
0
        public void Required_NotProvided_Three_Default()
        {
            Environment.SetEnvironmentVariable("ENV_STRING_DEFAULTABLE", null);

            var model = Cli.Parse <EnvVarsArgsModel>(new string[] { });

            Assert.Equal("DEFAULT_VALUE", model.EnvVarStringDefaulted);
        }
Exemplo n.º 13
0
        public void IncompatibleType()
        {
            Environment.SetEnvironmentVariable("ENV_INT", "FAIL");
            Environment.SetEnvironmentVariable("ENV_STRING", "HelloWorld");

            Assert.Throws <VariableTypeException>(
                () => Cli.Parse <EnvVarsArgsModel_Required>(new string[] { }));
        }
Exemplo n.º 14
0
        public void OperandMap_RequiredAttribute_Error()
        {
            string[] args = new string[] {
            };

            Assert.Throws <RequiredException>(
                () => Cli.Parse <OperandRequiredArgsModel>(args));
        }
Exemplo n.º 15
0
 public void RequiredNotProvided()
 {
     string[] args =
     {
     };
     Assert.Throws <RequiredException>(
         () => Cli.Parse <RequiredCliArguments>(args));
 }
        public void DuplicateArgs_SingleCase_alt()
        {
            string[] args = new string[] {
                "-aA"
            };

            Cli.Parse <DuplicateArgumentsModel>(args);
        }
Exemplo n.º 17
0
        public void Required_NotProvided_Two()
        {
            Environment.SetEnvironmentVariable("ENV_INT", "1");
            Environment.SetEnvironmentVariable("ENV_STRING", null);

            Assert.Throws <RequiredException>(
                () => Cli.Parse <EnvVarsArgsModel_Required>(new string[] { }));
        }
        public void DuplicateArgs_SimilarArgs_2()
        {
            string[] args = new string[] {
                "--log", "--log-level=1"
            };

            Cli.Parse <DuplicateSimilarOptionsModel>(args);
        }
Exemplo n.º 19
0
        public void RequiredMissing()
        {
            string[] args = new string[] {
                "--param-optional", "2",
            };

            Assert.Throws <RequiredException>(
                () => Cli.Parse <RequiredParameterArgsModel>(args));
        }
        public void Enums_InvalidType()
        {
            string[] args = new string[] {
                "--opt-1", "FAILITEM"
            };

            Assert.Throws <VariableTypeException>(
                () => Cli.Parse <EnumAppOptions>(args));
        }
        public void NotProvided()
        {
            string[] args = new string[] { };

            var model = Cli.Parse <StringArgsModel>(args);

            Assert.StrictEqual(null, model.DefaultNull);
            Assert.StrictEqual("NoName", model.DefaultNoName);
        }
        public void List_Bools_InvalidType()
        {
            string[] args = new string[] {
                "--booleans", "true,FAIL"
            };

            Assert.Throws <VariableTypeException>(
                () => Cli.Parse <ListsArgsModel>(args));
        }
        public void List_Ints_InvalidType()
        {
            string[] args = new string[] {
                "--integers", "1,2,3,FAIL"
            };

            Assert.Throws <VariableTypeException>(
                () => Cli.Parse <ListsArgsModel>(args));
        }
        public void List_NonStruct()
        {
            string[] args = new string[] {
                "--class", "param"
            };

            Assert.Throws <InvalidModelException>(
                () => Cli.Parse <ListsNonStructModel>(args));
        }
Exemplo n.º 25
0
        public void CaseIncorrect_Single()
        {
            string[] args = new string[] {
                "-O"
            };

            Assert.Throws <UnknownOptionException>(
                () => Cli.Parse <OptionArgsModel>(args));
        }
Exemplo n.º 26
0
 public void RequiredNotProvided_HelpInvoked()
 {
     string[] args =
     {
         "--help"
     };
     Assert.Throws <HelpTriggeredSuccessException>(
         () => Cli.Parse <RequiredCliArguments>(args));
 }
        public void NotProvided()
        {
            string[] args = new string[] { };

            var model = Cli.Parse <ParametersArgsModel>(args);

            Assert.StrictEqual(0, model.Param1);
            Assert.StrictEqual(7, model.Param2);
        }
Exemplo n.º 28
0
        public void Operands_NoParameters()
        {
            string[] args = new string[] {
            };

            var model = Cli.Parse <OperandDumpModel>(args);

            Assert.False(model.Operands.Any());
        }
        public void List_Decimals_InvalidType()
        {
            string[] args = new string[] {
                "--decimals", "1.1,2.1,FAIL,4.0"
            };

            Assert.Throws <VariableTypeException>(
                () => Cli.Parse <ListsArgsModel>(args));
        }
Exemplo n.º 30
0
        public void Required_NotProvided_Two_EmptyString()
        {
            Environment.SetEnvironmentVariable("ENV_INT", 1.ToString());
            Environment.SetEnvironmentVariable("ENV_STRING", "");

            // I don't like this but it's a known fact that "" will count as a deleted variable
            Assert.Throws <RequiredException>(
                () => Cli.Parse <EnvVarsArgsModel_Required>(new string[] { }));
        }