Dyalog / link

Source code for Link – the built-in component that enables the use of text files as the primary storage mechanism for APL source code
https://dyalog.github.io/link
MIT License
19 stars 12 forks source link

Confirm directory creation when using user command #599

Open bpbecker opened 1 year ago

bpbecker commented 1 year ago

Currently when one enters: ]create # /some/directory/name Link goes off and creates the directory if it doesn't exist (Link notifies you that the directory was created).

If you've mistyped/misremembered the folder name, you then need to:

WIBNI by default Link confirmed that it should create the directory when used from a user command, using the Link API would not prompt by default. There could be a new switch or setting "confirm=1|0" or something like that so one could disable the prompt (or enable it when using the API). I think this is a sensible feature because you're almost always you're going to be Link'ing to an existing directory so if the directory doesn't exist, it's far more likely that you've mistyped the name than you actually want to create a new directory. A simple confirmation prompt 'Directory "/some/directory/name" does not exist, create it (Y/n)? ' is minimally intrusive and saves the frustration of having to clean up when you've mistyped the name.

abrudz commented 1 year ago

I like the idea, but I think it needs to be more nuanced, as there are 4 possible scenarios:

  1. Dir exists, namespace exists
  2. Dir exists, namespace missing
  3. Dir missing, namespace exists
  4. Dir missing, namespace missing Obviously, we don't want to ask in case 1, but in which of the others should we ask, and what exactly should we ask?

I don't think an option is necessary. It is fine for user commands always to ask, and for API functions never to ask.

bpbecker commented 1 year ago

Yeah, I hadn't thought out all the scenarios - my posting the issue was a knee-jerk reaction to mistyping a directory name just now :).

We'd have to construct a prompt that handles cases 2-4 based on the non-existence of either the namespace, the directory, or both. It's a bit tedious, but doable...

I agree that the option isn't necessary for the user command case.