-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Persistent command history on Loop #75
Comments
It’s theoretically possible today using the exposed API, but would require too much work for the app. The right thing to do is for us to either add history persistence as a configurable feature or expose the command history interface as replaceable by the calling app. @javierbarre if I provided some guidance / pointers, are these changes something you might be interested in making in nclap and contributing back via PR? |
@reubeno with some guidance, yes I am interested. Thanks |
I took another look through the code. For What do you think, @javierbarre ? That could be a starting point. The application could then implement |
Great. I implemented persistence through the application as your suggested by implementing a new IConsoleHistory. Modifications: /// <summary>
/// Console History
/// </summary>
public IConsoleHistory ConsoleHistory { get; set; } And in CreateClient of Loop.cs: /// <summary>
/// Utility for constructing loop clients.
/// </summary>
/// <param name="parameters">I/O parameters for loop.</param>
/// <returns>A constructed loop client.</returns>
public static ILoopClient CreateClient(LoopInputOutputParameters parameters)
{
var consoleInput = parameters.ConsoleInput ?? BasicConsole.Default;
var consoleOutput = parameters.ConsoleOutput ?? BasicConsole.Default;
var keyBindingSet = parameters.KeyBindingSet ?? ConsoleKeyBindingSet.Default;
var consolehistory = parameters.ConsoleHistory ?? new ConsoleHistory(); // NEW LINE
var lineInput = parameters.LineInput ?? new ConsoleLineInput(
consoleOutput,
new ConsoleInputBuffer(),
consolehistory); // MODIFIED LINE
lineInput.Prompt = parameters.Prompt ?? Strings.DefaultPrompt;
var consoleReader = new ConsoleReader(lineInput, consoleInput, consoleOutput, keyBindingSet);
var consoleClient = new ConsoleLoopClient(consoleReader);
consoleClient.Reader.CommentCharacter = parameters.EndOfLineCommentCharacter;
return consoleClient;
} I needed to disable the
How can I get rid off these warnings? |
This is part of the mechanism we use to make sure we don't accidentally change the exposed interface of nclap without it being a conscious decision. If you navigate to the symbol in question, you should see a colored squiggly line beneath it in Visual Studio. There should also be a lightbulb icon that you can click on to auto-fix the issue; "fixing it" will add the API to the accepted allow-list of public API surface. If you have continued difficulty with this, please let us know. P.S. Sorry for the delay! |
Is it possible to make the command history persistent? Or save the commands entries to a local file?
In case there is not, can you provide Any example on how to access to the command history (_entries), and send a command to the prompt for execution?
The text was updated successfully, but these errors were encountered: