diff options
Diffstat (limited to 'Software/Visual_Studio/DataStore/Tango.DataStore.CLI/Program.cs')
| -rw-r--r-- | Software/Visual_Studio/DataStore/Tango.DataStore.CLI/Program.cs | 66 |
1 files changed, 5 insertions, 61 deletions
diff --git a/Software/Visual_Studio/DataStore/Tango.DataStore.CLI/Program.cs b/Software/Visual_Studio/DataStore/Tango.DataStore.CLI/Program.cs index db4f54620..85dfbb0bb 100644 --- a/Software/Visual_Studio/DataStore/Tango.DataStore.CLI/Program.cs +++ b/Software/Visual_Studio/DataStore/Tango.DataStore.CLI/Program.cs @@ -19,7 +19,7 @@ namespace Tango.DataStore.CLI { var console = new DataStoreConsole(); - var result = Parser.Default.ParseArguments<GetOptions, PutOptions>(args) + var result = Parser.Default.ParseArguments<GetOptions, PutOptions, LoginConfig>(args) .WithParsed<GetOptions>((options) => { console.Get(options); @@ -28,6 +28,10 @@ namespace Tango.DataStore.CLI { console.Put(options); }) + .WithParsed<LoginConfig>((options) => + { + console.AutoLogin(options); + }) .WithNotParsed((errors) => { @@ -41,64 +45,4 @@ namespace Tango.DataStore.CLI } } } - - public class DataStoreConsole - { - public void Get(GetOptions options) - { - try - { - if (options.MachineSerialNumber != null) - { - Console.WriteLine($"Retrieving data store values for '{options.MachineSerialNumber}'..."); - } - else - { - Console.WriteLine("Retrieving global data store values..."); - } - - var client = CreateClient(options.Email, options.Password, options.Environment); - - var items = client.Get(options.MachineSerialNumber, options.Collection, options.Key).ToList(); - - ConsoleTable table = new ConsoleTable("COLLECTION", "KEY", "DATA TYPE", "STATE", "GLOBAL", "LOCAL"); - - foreach (var item in items) - { - table.AddRow(item.Collection, item.Key, item.DataType, item.Type, item.GlobalValue.ToStringSafe().ToOneLine(), item.LocalValue.ToStringSafe().ToOneLine()); - } - - Console.WriteLine(); - Console.WriteLine("DATA STORE RESULTS:"); - Console.WriteLine(); - - table.Write(); - } - catch (Exception ex) - { - Console.WriteLine(ex.FlattenMessage()); - } - } - - public void Put(PutOptions options) - { - - } - - private DataStoreClient CreateClient(String email, String password, DeploymentSlot slot) - { - String token = String.Empty; - - HttpClient http = new HttpClient(); - DataStoreClient dsClient = new DataStoreClient(slot.ToAddress(), http); - var response = dsClient.Login(new LoginRequest() - { - Email = "roy@twine-s.com", - Password = "1Creativity", - }); - http.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", response.Token); - - return dsClient; - } - } } |
