-
Notifications
You must be signed in to change notification settings - Fork 392
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
Auto-recall for input prompts #3323
Comments
It would be interesting for the developer to be able to set a default or suggested value, especially for This behavior already exists with a lot of dialog windows, such as FileDialog.FileName, to provide a default file name. I'm talking about that now, as it is close to the subject. |
@marckruzik, this is a very good suggestion and I think it's fine to discuss here. The syntax would need to be a little different from your example, I think, since
The syntax should also consider the possibility of incorporating type hints and widgets. |
Do you have an example of multiple inputs in a single magic command? I looked at the code and cannot find any example in the tests. For now, if we are free to choose the syntax, I am thinking about the following (not including widgets as I don't know them). The array of strings-like
It will work only for strings, and relies too heavily on the order. The anonymous object-like
Better than an array, and closer to an anonymous object. The method-like
Close to named parameters. About the complex syntaxOf course, we keep the simple syntax |
These are all good suggestions and more readable that what I've sketched so far, which looks like this:
What's driving this more compressed syntax is that the parser for magic commands (System.CommandLine) follows command line grammar rules, so spaces (unless surrounded by quotes) delineate different arguments. The syntax I've proposed avoids that. But I'm not really satisfied with it. We're considering a significant change to the grammar here to depart from command line limitations. This would open the door to more readable suggestions like yours as well as the possibility of better support for completions and other language services. |
Take a look at #3194. The idea would be that when there are multiple inputs in a single magic command, to present a form instead of a series of one-at-a-time VS Code text boxes. The type of inputs presented would lean on the type hint system and (as you already showed in your own examples) require a way to specify a type hint for each given |
Ok I see.
I just found this post from you talking about the issue. I think this issue is far more bigger than Polyglot, it's more related to CommandLine, and even to all CLI systems. I already encountered this problem several times, and did not found a library or any standard to answer it.
Quote escaping can be tricky, so sometimes I replaced double quotes by other symbols, such as I also sometimes put "the parameter" into a configuration file. Here is an example from a Windows batch:
Some of my work included ways for a web browser to communicate with local executables, so I used a lot of ways for data to work with both a CLI and a browser, and looking the same way to facilitate development. |
System.CommandLine's custom parse delegates solved this issue. But the ability to have whitespace not be treated as a delimiter between arguments/options is something that could work nicely for magic commands, and can't work for CLI parsers. We're looking into a new magic command parser more tailored to this use case, and what grammar we might prefer in that case. |
Another possibility would be to support directly inlining JSON into the magic command in these cases:
|
I agree inline JSON would be an interesting idea. As a later development, if JSON inlining becomes a thing, I would be interested to use |
This work depends on #3567. |
The
@input
and@password
prompts today don’t have a way to recall values that were entered on past runs. Adding a gesture to instruct the prompt to save its value could be a helpful ergonomic improvement even for values that aren’t secrets. For example, many tutorial notebooks ask for a file path on disk, and for any given user, that file path is probably not going to change from run to run. Restarting the kernel is a common notebook interaction and this flushes the in-memory prompt results, requiring the user to re-enter them. Enabling the prompt to check for a remembered response and re-use it without re-issuing the prompt to the user could help make many notebook workflows faster and smoother.There are several ways we could approach implementing this.
Most inputs stored this way would be stored in the user’s profile as plain text files (likely containing JSON), with the exception of values ingested by the
@password
token. The current best candidate for storing these would be the PowerShell SecretManagement and SecretStore modules, but other possibilities can be evaluated.Matching could be done based on the complete text of a given magic command. So, for example, the @input prompts for each of these two examples would never access a value stored by the other:
There are a few different UX flows that could work for storage and recall:
• The user could be prompted to store the value.
• The user could be prompted to recall the value.
• There could be a way to make storage and recall the default behavior in order to further reduce redundant interactions. (For example, there could be a separate magic command that sets this preference at the notebook level.)
The text was updated successfully, but these errors were encountered: