示例#1
0
        public TaskPackageFile(string filename)
        {
            Filename = filename;

            Console.WriteLine($"Reading Package from {filename}");
            try
            {
                foreach (var line in File.ReadAllLines(Filename).Where(t => t.Trim().Any()))
                {
                    var args = ConsoleProgram.ExpandCommand(line);
                    AddTask(args.ToConsoleTask());
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("The package file could not be read:");
                Console.WriteLine(e.Message);
            }
        }
示例#2
0
        /// <summary>
        /// Provides built-in confirmation before executing by prompting user to press 'y'
        /// override for specialized confirmation
        /// </summary>
        /// <returns></returns>
        public virtual bool ConfirmStart()
        {
            bool executionPreAuthorized = Silent;
            var  executionAuthorized    = executionPreAuthorized;
            var  isTaskValid            = RequiredArgumentsPresent();

            // Can't assume the user wants to write the arguments in an override
            //if (!GetType().NoConfirmation())
            //    WriteArguments();

            if (isTaskValid)
            {
                if (!executionPreAuthorized)
                {
                    var consoleInfo = ConsoleProgram.ConsolePrompt();
                    executionAuthorized = (consoleInfo.KeyChar == 'Y' || consoleInfo.KeyChar == 'y');
                }
            }

            return(executionAuthorized && isTaskValid);
        }