Пример #1
0
 /// <summary>
 /// Execute command
 /// </summary>
 /// <param name="cmd">Command</param>
 private void Execute(string cmd)
 {
     try
     {
         Exec.Exec(cmd);
     }
     catch (Exception ex)
     {
         CliHelpers.WriteLine(ex, ConsoleColor.Red);
     }
 }
Пример #2
0
        /// <summary>
        /// Execute commands in loop
        /// </summary>
        private void ExecuteInLoop()
        {
            //
            // Quit
            Exec.Register("quit", (p) => Stop());

            //
            // Clear screen
            Exec.Register("cls", (p) => Console.Clear());

            Console.WriteLine();

            while (Running)
            {
                CliHelpers.Write("> ", ConsoleColor.White);
                Execute(Console.ReadLine());
            }
        }
Пример #3
0
        /// <summary>
        /// Print help (documentation)
        /// </summary>
        protected virtual void PrintHelp()
        {
            #region Print header
            CliHelpers.WriteLine();
            CliHelpers.WriteLine(Assembly.GetExecutingAssembly().FullName, ConsoleColor.White);
            CliHelpers.WriteLine(Environment.OSVersion, ConsoleColor.Gray);
            CliHelpers.WriteLine();
            #endregion

            foreach (var cmd in Exec.Cmds)
            {
                #region Print command
                CliHelpers.WriteLine(cmd, ConsoleColor.Cyan);
                CliHelpers.WriteLine(Exec.GetDoc(cmd), ConsoleColor.Gray);
                CliHelpers.WriteLine();
                #endregion
            }

            CliHelpers.WriteLine(new string('-', 5));
            CliHelpers.WriteLine();
        }