diff --git a/src/Certify.CLI/CertifyCLI,StoredCredentials.cs b/src/Certify.CLI/CertifyCLI.StoredCredentials.cs similarity index 52% rename from src/Certify.CLI/CertifyCLI,StoredCredentials.cs rename to src/Certify.CLI/CertifyCLI.StoredCredentials.cs index 11d4a9620..3c4d20934 100644 --- a/src/Certify.CLI/CertifyCLI,StoredCredentials.cs +++ b/src/Certify.CLI/CertifyCLI.StoredCredentials.cs @@ -25,25 +25,32 @@ internal async Task UpdateStoredCredential(string[] args) var cred = new StoredCredential { StorageKey = storageKey, - DateCreated = DateTime.Now, + DateCreated = DateTime.UtcNow, ProviderType = credentialType, Secret = secretValue, Title = title }; - var result = await _certifyClient.UpdateCredentials(cred); - - if (result != null) + try { - var resultObject = new { Status = "OK", Message = "Credential updated", StorageKey = result?.StorageKey }; - var output = JsonConvert.SerializeObject(resultObject, Formatting.Indented); - Console.WriteLine(output); + var result = await _certifyClient.UpdateCredentials(cred); + if (result != null) + { + + var resultObject = new { Status = "OK", Message = "Credential updated", StorageKey = result?.StorageKey }; + var output = JsonConvert.SerializeObject(resultObject, Formatting.Indented); + Console.WriteLine(output); + } + else + { + var resultObject = new { Status = "Error", Message = "Credential update failed" }; + var output = JsonConvert.SerializeObject(resultObject, Formatting.Indented); + Console.WriteLine(output); + } } - else + catch (Exception ex) { - var resultObject = new { Status = "Error", Message = "Credential update failed" }; - var output = JsonConvert.SerializeObject(resultObject, Formatting.Indented); - Console.WriteLine(output); + Console.WriteLine($"Error updating credentials: {ex.Message}"); } } @@ -55,5 +62,10 @@ internal async Task ListStoredCredentials(string[] args) Console.WriteLine(output); } + private void WriteOutput(object resultObject) + { + var output = JsonConvert.SerializeObject(resultObject, Formatting.Indented); + Console.WriteLine(output); + } } }