private void setAliasToolStripMenuItem_Click(object sender, EventArgs e) { if (_selectedTable != null) { var dlg = new frmSetAlias(); dlg.Table = _selectedTable.Table; dlg.AliasManager = _aliasManager; if (dlg.ShowDialog() == DialogResult.OK) { _aliasManager.Aliases[dlg.Alias] = _selectedTable.Table.ToString(); _aliasManager.Save(); _selectedTable.Alias = dlg.Alias; } } }
/// <summary> /// Start interactive shell /// </summary> /// <param name="client"></param> /// <param name="fileScript"></param> /// <param name="onlyResult"></param> public static void Start(PveClient client, string fileScript, bool onlyResult) { if (!onlyResult) { Console.Out.WriteLine($@"Corsinvest Interactive Shell for Proxmox VE ({DateTime.Now.ToLongDateString()}) Type '<TAB>' for completion word Type 'help', 'quit' or 'CTRL+C' to close the application."); } #region ClassApi Metadata var watch = Stopwatch.StartNew(); if (!onlyResult) { Console.Out.Write("Initialization metadata..."); } //get api metadata var classApiRoot = GeneretorClassApi.Generate(client.Hostname, client.Port); watch.Stop(); if (!onlyResult) { Console.Out.WriteLine($" {watch.ElapsedMilliseconds}ms"); } #endregion if (!onlyResult) { Console.Out.WriteLine(Environment.NewLine + ShellHelper.REMEMBER_THESE_THINGS); } //Auto Completion ReadLine.AutoCompletionHandler = new AutoCompletionHandler() { Client = client, ClassApiRoot = classApiRoot }; LoadHistory(); var aliasManager = new AliasManager() { FileName = Path.Combine(ShellHelper.GetApplicationDataDirectory(Program.APP_NAME), "alias.txt") }; aliasManager.Load(); if (File.Exists(fileScript)) { //script file foreach (var line in File.ReadAllLines(fileScript)) { ParseLine(line, client, classApiRoot, aliasManager, onlyResult); } } else { //Interactive while (true) { var input = ReadLine.Read(">>> "); var exit = ParseLine(input, client, classApiRoot, aliasManager, onlyResult); SaveHistory(); aliasManager.Save(); if (exit) { break; } } } }