src/Keypear.CliClient/CliModel/MainCommand.cs
/// <summary>
/// Resolves a Vault reference to a specific Vault instance, or failing
/// that, will print an appropriate error message to console and return
/// <c>null</c>.
/// </summary>
Resolves a Vault reference to a specific Vault instance, or failing
that, will print an appropriate error message to console and return
null
Resolves a Vault reference to a specific Vault instance or failing that will print an appropriate error message to console and return null
public Vault? GetVault(KyprClient client, string vaultRef)
    {
        client.UnlockVaults();
        var vaults = client.ListVaults().Where(x =>
            x.Id.ToString()!.StartsWith(vaultRef!, StringComparison.OrdinalIgnoreCase));
        if (vaults.Count() == 0)
        {
            vaults = client.ListVaults().Where(x =>
                x.Summary!.Label!.StartsWith(vaultRef!, StringComparison.OrdinalIgnoreCase));
        }
        if (vaults.Count() == 0)
        {
            _console.WriteError("no Vaults match the specified reference.");
            return null;
        }
        if (vaults.Count() > 1)
        {
            _console.WriteError("multiple Vaults match the specified reference.");
            return null;
        }
        return vaults.Single();
    }
public Vault ? GetVault ( KyprClient client , string vaultRef ) { client . UnlockVaults ( ) ; var vaults = client . ListVaults ( ) . Where ( x => x . Id . ToString ( ) ! . StartsWith ( vaultRef ! , StringComparison . OrdinalIgnoreCase ) ) ; if ( vaults . Count ( ) == 0 ) { vaults = client . ListVaults ( ) . Where ( x => x . Summary ! . Label ! . StartsWith ( vaultRef ! , StringComparison . OrdinalIgnoreCase ) ) ; } if ( vaults . Count ( ) == 0 ) { _console . WriteError ( " " ) ; return null ; } if ( vaults . Count ( ) > 1 ) { _console . WriteError ( " " ) ; return null ; } return vaults . Single ( ) ; }
Resolves a Vault reference to a specific Vault instance, or failing
that, will print an appropriate error message to console and return
null
Resolves a Vault reference to a specific Vault instance or failing that will print an appropriate error message to console and return null
// First try by Id // Next try by label
client
KyprClient
vaultRef
string