private static void OutputCommandInfo(RunInfoBase runInfo) { CM.WriteLineColoredReset(@" _____ _____ ____ _____ | __| __| \| __ | | __| __| | | __ -| |__| |__| |____/|_____|", ConsoleColor.Cyan); CM.WriteLineColoredReset(" v1.0.0-alpha.1" + Environment.NewLine, ConsoleColor.White); Write("Running command: "); CM.WriteLineColoredReset(runInfo.CommandKey, ConsoleColor.Yellow); WriteLine(runInfo.Description + Environment.NewLine); }
internal static EngineSetup ConfigureFromRunInfo(this EngineSetup setup, RunInfoBase runInfo) { if (runInfo.SkipRosterFetch) { setup.SkipRosterFetch(); } if (runInfo.SaveToDisk) { setup.SaveToDisk(); } if (runInfo.SaveOriginalSourceFiles) { setup.SaveOriginalSourceFiles(); } return(setup); }
private static string GetConfigFilePath(RunInfoBase runInfo) { string path = runInfo.ConfigFilePath; if (string.IsNullOrWhiteSpace(path) || !File.Exists(path)) { path = "ffdb_config.json"; if (!File.Exists(path)) { throw new InvalidOperationException("Failed to find config file. Ensure that you either include it as a program option " + "or that the file exists (named as 'ffdb_config.json') in the same dir as the program exe."); } } return(path); }
private static bool TryGetRunInfo(string[] args, out RunInfoBase runInfo) { runInfo = null; var runInfoBuilder = ConfigureRunInfoBuilder.Create(); var result = runInfoBuilder.Build(args); if (result == null) { // version or help command return(false); } runInfo = result as RunInfoBase; return(true); }
internal static FfdbEngine Resolve(FfdbConfig config, RunInfoBase runInfo, DataRepoState dataRepoState) { var setup = new EngineSetup() .SetRootDataDirectoryPath(config.RootDataPath) .ConfigureWebClient(config) .ConfigureLogging(config) .ConfigureDbProvider(config) .ConfigureFromRunInfo(runInfo); bool fetchFromDataRepo = dataRepoState?.Enabled ?? false; if (fetchFromDataRepo) { setup.EnableFetchingFromDataRepo(); } return(setup.Create()); }
public async Task RunAsync(RunInfoBase runInfo) { if (runInfo is InitialSetup.RunInfo initialSetup) { await RunInitialSetupAsync(initialSetup); return; } bool ffdbInitialized = await _engine.HasBeenInitializedAsync(); if (!ffdbInitialized) { throw new InvalidOperationException("Initial setup must first be run before " + $"you can use command '{runInfo.CommandKey}'."); } switch (runInfo) { case UpdateRosters.RunInfo _: await RunRostersUpdateAsync(); break; case AddStats.RunInfo addStats: await RunAddStatsAsync(addStats); break; case UpdateRosteredPlayers.RunInfo updatePlayers: await RunUpdatePlayersAsync(updatePlayers); break; case ViewState.RunInfo _: await RunViewStateAsync(); break; default: throw new ArgumentOutOfRangeException($"'{runInfo.GetType().Name}' is an invalid '{nameof(RunInfoBase)}' type."); } }