Confirm directory creation when using user command
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:
- break the link
- delete the newly created folder
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.
I like the idea, but I think it needs to be more nuanced, as there are 4 possible scenarios:
- Dir exists, namespace exists
- Dir exists, namespace missing
- Dir missing, namespace exists
- 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.
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...
- 'Namespace "#.foo" does not exist, create it?'
- 'Directory "/foo/boo" does not exist, create it?'
- 'Namespace "#.foo" and directory "/foo/boo" do not exist, create them?'
I agree that the option isn't necessary for the user command case.