protected override async Task <int> OnExecuteTorrentSpecificAsync(QBittorrentClient client, CommandLineApplication app, IConsole console) { var partialData = await client.GetPartialDataAsync(); if (!partialData.TorrentsChanged.TryGetValue(Hash, out var info)) { console.WriteLineColored($"No torrent matching hash {Hash} is found.", ColorScheme.Current.Warning); return(ExitCodes.NotFound); } var ratioLimit = GetRatioLimit(); var seedingTimeLimit = GetSeedingTimeLimit(); if (ratioLimit != null || seedingTimeLimit != null) { await client.SetShareLimitsAsync(Hash, ratioLimit ?? info.RatioLimit ?? ShareLimits.Ratio.Global, seedingTimeLimit ?? info.SeedingTimeLimit ?? ShareLimits.SeedingTime.Global); return(ExitCodes.Success); } var(properties, global) = await TaskHelper.WhenAll( client.GetTorrentPropertiesAsync(Hash), client.GetPreferencesAsync()); var viewModel = new TorrentShareViewModel(properties, info); _customFormatters = new Dictionary <string, Func <object, object> > { [nameof(viewModel.RatioLimit)] = FormatRatioLimit, [nameof(viewModel.SeedingTimeLimit)] = FormatSeedingTimeLimit }; Print(viewModel); return(ExitCodes.Success); object FormatRatioLimit(object arg) { switch (arg) { case double value when Math.Abs(value - ShareLimits.Ratio.Global) < 0.0001: var globalValue = global.MaxRatio >= 0 ? global.MaxRatio.Value.ToString("F3") : "None"; return($"Global ({globalValue})"); case double value when Math.Abs(value - ShareLimits.Ratio.Unlimited) < 0.0001: return("None"); case double value: return(value.ToString("F3")); default: return(null); } } object FormatSeedingTimeLimit(object arg) { var time = arg as TimeSpan?; if (time == ShareLimits.SeedingTime.Global) { var globalValue = global.MaxSeedingTime >= 0 ? global.MaxSeedingTime.Value.ToString() : "None"; return($"Global ({globalValue})"); } return(time == ShareLimits.SeedingTime.Unlimited ? "None" : time?.ToString()); } }