Example #1
0
        /// <summary>
        /// Saves Command Text History
        /// </summary>
        public static void Save(IPromptConfiguration config)
        {
            var historyFile = config.GetOption("HistoryFile");

            if (string.IsNullOrEmpty(historyFile))
            {
                return;
            }

            var history = ReadLine.GetHistory();

            history = history.Distinct().ToList(); // Remove duplicates
            File.WriteAllLines(historyFile, history);
        }
Example #2
0
        /// <summary>
        /// Load Command Text History
        /// </summary>
        public static void Load(IPromptConfiguration config)
        {
            var historyFile = config.GetOption("HistoryFile");

            if (string.IsNullOrEmpty(historyFile))
            {
                return;
            }


            ReadLine.HistoryEnabled = true;
            if (!File.Exists(historyFile))
            {
                return;
            }
            var history = File.ReadAllLines(historyFile);

            ReadLine.AddHistory(history);
        }
Example #3
0
        public Prompt(IPromptConfiguration configuration)
        {
            try
            {
                // If Configuration is null, use default settings
                Configuration = configuration ?? new PromptConfiguration();

                ReadLine.HistoryEnabled = string.Equals(Configuration.GetOption("HistoryEnabled"), true.ToString());

                BuildCommands.ScanForPrompt(this);

                HistoryFile.Load(configuration);
            }
            catch (Exception e)
            {
                // Don't allow an exception to crash the application by a throw
                // Show the error so that an developer can fix the problem.
                Console.WriteLine(e);
            }
        }