Esempio n. 1
0
        public override bool ConfirmStart()
        {
            if (string.IsNullOrEmpty(Filename))
            {
                if (string.IsNullOrEmpty(Name))
                {
                    Console.WriteLine($"RunPackage requires either a name or a filename to execute");
                    return(false);
                }
                else
                {
                    //activate & load the package
                    Console.WriteLine($"Activating Package {Name}");
                    package = PackageLibrary.GetPackage(Name);
                    if (package == null)
                    {
                        Console.WriteLine($"Package [{Name}] not found.\n\nSC> GetPackages\n");

                        // run GetPackages for the user
                        ConsoleProgram.StartTask("GetPackages");
                        Console.WriteLine($"\n\n");

                        return(false);
                    }
                }
            }
            else
            {
                package = new TaskPackageFile(Filename);
            }

            return(base.ConfirmStart());
        }
Esempio n. 2
0
 void RunTestGroup(List <string> testGroup)
 {
     foreach (var test in testGroup)
     {
         Console.WriteLine($"   Command: {test}");
         ConsoleProgram.StartTask(test);
     }
 }
Esempio n. 3
0
        public override TaskResult StartTask()
        {
            // Read a command line and perform the tasks over
            // and over

            string       command;
            const string helpCommand = "help -Usagetext \"SHELL Usage: <Task Name> [task options]\n\"";

            Console.WriteLine($"{System.AppDomain.CurrentDomain.FriendlyName} Shell\n");
            Console.WriteLine("'exit', 'quit' or 'q' to quit");
            Console.WriteLine("'?' or 'help' for help\n");

            do
            {
                Console.Write("SC> ");
                { command = Console.ReadLine().Trim(); }

                if (command.ToLower() == "quit")
                {
                    break;
                }
                if (command.ToLower() == "q")
                {
                    break;
                }
                if (command.ToLower() == "exit")
                {
                    break;
                }

                // augment requests for help
                if (
                    command.Equals("?") ||
                    command.ToLower().Equals("help"))
                {
                    command = helpCommand;
                }

                if (command.Length > 0)
                {
                    try
                    {
                        var result = ConsoleProgram.StartTask(command);

                        if (!string.IsNullOrEmpty(result.Message))
                        {
                            Console.WriteLine($"[{result.ResultCode}]:\n{result.Message}\n");
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine($"An exception ocurred: {ex.Message}");
                    }
                }
            } while (true);

            return(new TaskResult()
            {
                IsSuccessful = true, Message = "exiting SmartConsole Shell"
            });
        }