public InputSettings(string[] args)
 {
     LanguageStorePath    = CliArgumentsReader.GetOptionValue(args, LanguageStorePathOptions);
     LocationStorePath    = CliArgumentsReader.GetOptionValue(args, LocationsStorePathOptions);
     TitleStorePath       = CliArgumentsReader.GetOptionValue(args, TitleStorePathOptions);
     LandedTitlesFilePath = CliArgumentsReader.TryGetOptionValue(args, LandedTitlesFilePathOptions);
 }
Ejemplo n.º 2
0
        static StreamProvider DetermineProviderFromArgs(string[] args)
        {
            if (CliArgumentsReader.HasOption(args, YouTubeProcessorOptions))
            {
                return(StreamProvider.YouTube);
            }

            if (CliArgumentsReader.HasOption(args, TwitchProcessorOptions))
            {
                return(StreamProvider.Twitch);
            }

            if (CliArgumentsReader.HasOption(args, SeeNowProcessorOptions))
            {
                return(StreamProvider.SeeNow);
            }

            if (CliArgumentsReader.HasOption(args, TvSportHdProcessorOptions))
            {
                return(StreamProvider.TvSportHd);
            }

            if (CliArgumentsReader.HasOption(args, AntenaPlayProccessorOptions))
            {
                return(StreamProvider.AntenaPlay);
            }

            if (CliArgumentsReader.HasOption(args, OkLiveProcessorOptions))
            {
                return(StreamProvider.OkLive);
            }

            return(StreamProvider.Other);
        }
        /// <summary>
        /// The entry point of the program, where the program control starts and ends.
        /// </summary>
        /// <param name="args">CLI arguments</param>
        public static void Main(string[] args)
        {
            string inputFilePath  = CliArgumentsReader.GetOptionValue(args, InputFileOptions);
            string outputFilePath = CliArgumentsReader.GetOptionValue(args, OutputFileOptions);
            string namelistName   = CliArgumentsReader.GetOptionValue(args, NameOptions);
            bool   isLocked       = CliArgumentsReader.HasOption(args, IsLockedOptions);

            IShipNamesBuilder      shipNamesBuilder      = new ShipNamesBuilder();
            IShipClassNamesBuilder shipClassNamesBuilder = new ShipClassNamesBuilder();
            IFleetNamesBuilder     fleetnamesBuilder     = new FleetNamesBuilder();
            IArmyNamesBuilder      armyNamesBuilder      = new ArmyNamesBuilder();
            IPlanetNamesBuilder    planetNamesBuilder    = new PlanetNamesBuilder();
            ICharacterNamesBuilder characterNamesBuilder = new CharacterNamesBuilder();

            IFileContentBuilder fileContentBuilder = new FileContentBuilder(
                shipNamesBuilder,
                shipClassNamesBuilder,
                fleetnamesBuilder,
                armyNamesBuilder,
                planetNamesBuilder,
                characterNamesBuilder);

            IRepository <NameList> nameListRepository = new XmlRepository <NameList>(inputFilePath);
            INameListGenerator     nameListGenerator  = new NameListGenerator(fileContentBuilder, nameListRepository);

            nameListGenerator.Generate(outputFilePath, namelistName, isLocked);
        }
Ejemplo n.º 4
0
        public void TryGetOptionValue_OptionExistsWithoutValue_ThrowsArgumentNullException()
        {
            string option = "--option";

            string[] args = { "--test", option, "--bla2" };

            Assert.That(CliArgumentsReader.TryGetOptionValue(args, option), Is.Null);
        }
Ejemplo n.º 5
0
        public void GetOptionValue_OptionExistsWithoutValue_ThrowsArgumentNullException()
        {
            string option = "--option";

            string[] args = { "--test", option, "--bla2" };

            Assert.Throws <ArgumentNullException>(() => CliArgumentsReader.GetOptionValue(args, option));
        }
Ejemplo n.º 6
0
        static string GetArgumentIfExists(string[] args, string[] argumentOptions, string fallbackValue)
        {
            if (CliArgumentsReader.HasOption(args, argumentOptions))
            {
                return(CliArgumentsReader.GetOptionValue(args, argumentOptions));
            }

            return(fallbackValue);
        }
Ejemplo n.º 7
0
 public ModSettings(string[] args)
 {
     Id          = CliArgumentsReader.GetOptionValue(args, IdOptions);
     Name        = CliArgumentsReader.GetOptionValue(args, NameOptions);
     Version     = CliArgumentsReader.GetOptionValue(args, VersionOptions);
     Dependency  = CliArgumentsReader.TryGetOptionValue(args, DependencyOptions);
     Game        = CliArgumentsReader.GetOptionValue(args, GameOptions);
     GameVersion = CliArgumentsReader.GetOptionValue(args, GameVersionOptions);
 }
Ejemplo n.º 8
0
        public void TryGetOptionValue_OptionExistsWithValueAsSameArgument_ReturnsTheValue()
        {
            string option = "--option";
            string value  = "value";

            string[] args = { "--test", $"{option}={value}", "--bla2" };

            Assert.AreEqual(value, CliArgumentsReader.TryGetOptionValue(args, option));
        }
Ejemplo n.º 9
0
        public void GetOptionValue_OptionExistsWithValueAsDifferentArgument_ReturnsTheValue()
        {
            string option = "--option";
            string value  = "value";

            string[] args = { "--test", option, value, "--bla2" };

            Assert.AreEqual(value, CliArgumentsReader.GetOptionValue(args, option));
        }
Ejemplo n.º 10
0
        static ApplicationSettings GetSettings(string[] args)
        {
            ApplicationSettings settings = new ApplicationSettings();

            settings.Username        = CliArgumentsReader.GetOptionValue(args, UsernameOptions);
            settings.SharedSecretKey = CliArgumentsReader.GetOptionValue(args, SecretKeyOptions);

            if (CliArgumentsReader.HasOption(args, PlatformOptions))
            {
                settings.Platform = CliArgumentsReader.GetOptionValue(args, PlatformOptions);
            }
            else
            {
                settings.Platform = GetPlatformFromDepsFile();

                if (string.IsNullOrWhiteSpace(settings.Platform))
                {
                    settings.Platform = FileHandler.ReadValue(LauncherInfo.PlaformFilePath, "linux-x64");
                }
            }

            return(settings);
        }
 public OutputSettings(string[] args)
 {
     ModOutputDirectory        = CliArgumentsReader.GetOptionValue(args, OutputDirectoryPathOptions);
     AreVerboseCommentsEnabled = CliArgumentsReader.HasOption(args, VerboseCommentsOptions);
     LandedTitlesFileName      = CliArgumentsReader.TryGetOptionValue(args, LandedTitlesFileNameOptions);
 }
Ejemplo n.º 12
0
        static GeneratorSettings LoadSettings(string[] args)
        {
            GeneratorSettings settings = new GeneratorSettings();

            if (CliArgumentsReader.HasOption(args, SeedOptions))
            {
                settings.Seed = int.Parse(CliArgumentsReader.GetOptionValue(args, SeedOptions));
            }

            settings.GameDirectoryPath = CliArgumentsReader.GetOptionValue(args, ImperatorDirectoryPathOptions);
            settings.ModName           = CliArgumentsReader.GetOptionValue(args, ModNameOptions);

            if (CliArgumentsReader.HasOption(args, CapitalPopulationOptions))
            {
                settings.CapitalPopulation = int.Parse(CliArgumentsReader.GetOptionValue(args, CapitalPopulationOptions));
            }

            if (CliArgumentsReader.HasOption(args, CityPopulationMinOptions))
            {
                settings.CityPopulationMin = int.Parse(CliArgumentsReader.GetOptionValue(args, CityPopulationMinOptions));
            }

            if (CliArgumentsReader.HasOption(args, CityPopulationMaxOptions))
            {
                settings.CityPopulationMax = int.Parse(CliArgumentsReader.GetOptionValue(args, CityPopulationMaxOptions));
            }

            if (CliArgumentsReader.HasOption(args, CityCivilisationLevelMinOptions))
            {
                settings.CityCivilisationLevelMin = int.Parse(CliArgumentsReader.GetOptionValue(args, CityCivilisationLevelMinOptions));
            }

            if (CliArgumentsReader.HasOption(args, CityCivilisationLevelMaxOptions))
            {
                settings.CityCivilisationLevelMax = int.Parse(CliArgumentsReader.GetOptionValue(args, CityCivilisationLevelMaxOptions));
            }

            if (CliArgumentsReader.HasOption(args, CityBarbarianLevelMinOptions))
            {
                settings.CityBarbarianLevelMin = int.Parse(CliArgumentsReader.GetOptionValue(args, CityBarbarianLevelMinOptions));
            }

            if (CliArgumentsReader.HasOption(args, CityBarbarianLevelMaxOptions))
            {
                settings.CityBarbarianLevelMax = int.Parse(CliArgumentsReader.GetOptionValue(args, CityBarbarianLevelMaxOptions));
            }

            if (CliArgumentsReader.HasOption(args, CountryCentralisationLevelMinOptions))
            {
                settings.CountryCentralisationLevelMin = int.Parse(CliArgumentsReader.GetOptionValue(args, CountryCentralisationLevelMinOptions));
            }

            if (CliArgumentsReader.HasOption(args, CountryCentralisationLevelMaxOptions))
            {
                settings.CountryCentralisationLevelMax = int.Parse(CliArgumentsReader.GetOptionValue(args, CountryCentralisationLevelMaxOptions));
            }

            if (CliArgumentsReader.HasOption(args, RandomCountriesCountOptions))
            {
                settings.RandomCountriesCount = int.Parse(CliArgumentsReader.GetOptionValue(args, RandomCountriesCountOptions));
            }

            return(settings);
        }
Ejemplo n.º 13
0
        public void HasOption_CalledWithOneVariant_OptionExists_ReturnsTrue()
        {
            string[] args = { "--test", "--bla", "--bla2" };

            Assert.IsTrue(CliArgumentsReader.HasOption(args, "--test"));
        }
Ejemplo n.º 14
0
        public void GetOptionValue_OptionDoesNotExist_ThrowsArgumentException()
        {
            string[] args = { "--test", "--bla", "--bla2" };

            Assert.Throws <ArgumentException>(() => CliArgumentsReader.GetOptionValue(args, "--hori"));
        }
Ejemplo n.º 15
0
        public void HasOption_OptionDoesNotExist_ReturnsFalse()
        {
            string[] args = { "--test", "--bla", "--bla2" };

            Assert.IsFalse(CliArgumentsReader.HasOption(args, "--hori"));
        }
Ejemplo n.º 16
0
        public void TryGetOptionValue_OptionDoesNotExist_ThrowsArgumentException()
        {
            string[] args = { "--test", "--bla", "--bla2" };

            Assert.That(CliArgumentsReader.TryGetOptionValue(args, "--hori"), Is.Null);
        }