/// <inheritdoc /> public override ExitCode Execute() { var trustDB = TrustDB.Load(); switch (AdditionalArgs.Count) { case 0: if (Handler.IsGui) { Config.InitialTab = ConfigTab.Trust; Handler.Output(Resources.Configuration, Config); } else { Handler.Output(Resources.TrustedKeys, trustDB.Keys); } return(ExitCode.OK); case 1: string fingerprint = AdditionalArgs[0]; Handler.Output( string.Format(Resources.TrustedForDomains, fingerprint), trustDB.Keys.FirstOrDefault(x => x.Fingerprint == fingerprint)?.Domains ?? new()); return(ExitCode.OK); default: throw new InvalidOperationException(); } }
/// <inheritdoc /> public override ExitCode Execute() { var trustDB = TrustDB.Load(); string fingerprint = AdditionalArgs[0]; var domain = new Domain(AdditionalArgs[1]); if (trustDB.IsTrusted(fingerprint, domain)) { return(ExitCode.NoChanges); } trustDB.TrustKey(fingerprint, domain); trustDB.Save(); return(ExitCode.OK); }
/// <inheritdoc /> public override ExitCode Execute() { var trustDB = TrustDB.Load(); bool found = AdditionalArgs.Count switch { 1 => trustDB.UntrustKey(AdditionalArgs[0]), 2 => trustDB.UntrustKey(AdditionalArgs[0], new(AdditionalArgs[1])), _ => throw new InvalidOperationException() }; if (!found) { return(ExitCode.NoChanges); } trustDB.Save(); return(ExitCode.OK); } }