-
Notifications
You must be signed in to change notification settings - Fork 3
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
Allow mkdir
command to create multiple directories
#300
Conversation
How do I handle sending the warning to the user? Should a random warning message be simply sent to [aryanj@matrix-34xx:~]$ pk secrets mkdir vault:dir
WARNING: Empty directories will not be affected by modifications to the vault state (version change, sharing/cloning, etc.). It seems a bit random how Like I discussed in Polykey#819, it would probably be better if instead of passing an error message, we instead return an object containing details of the error (serialising the error will probably take up too much bandwidth for minimal to no return), which can then be interpreted by the client (CLI) to adapt to their own needs. For example, when we make a Polykey Desktop, then the error messages we have are designed for UNIX CLI and would feel awkward on other clients. Instead of relying on UNIX's behaviour and messages, which itself doesn't follow a strict standard, we should devise our own standard of printing warnings and errors. This is different to the formatters, as the formatters will format a certain type of output in a certain way. We, however, need a standard of message content. We also need a standard way to display these warnings/errors. It could be made using a new formatter, it could be made using the logger. It doesn't matter how we get consistency, but I'd say consistency in user experience is something pretty important. |
Yeah we'll want a standard way of dealing with this but it doesn't need to be a fully serialized version of the Error object itself. Create a standard error message under the client types and have all rm, cat and mkdir conform to this structure when sending the details of the error. This is only for expected errors from the FS. If it was an unexpected error the we still throw it using the normal methods. You'll need a way to tell the errors from the normal messages. for this you'd use a typed object for pattern matching the messages. So we'd have type Message = {
//...whatever
}
type ErrorMessage = {
type: 'error',
//...whatever
}
type HandlerMessage = Message | ErrorMessage; So typescript is smart enough to tell the two apart. You can pattern match for one or the other implcity by checking if if (message.type === 'error') {
// message will by typed as a ErrorMessage here implicitly.
} else {
// message is now a Message here.
} Use this to tell them apart on the client side and construct our formatted message. As for what to make the error message. Just include the minimal details of the error we need to know. Message, error name, code and exit code if applicable. |
I implemented this here, Polykey#819, but I ran into an interesting issue. Typescript doesn't actually quite work like this. If only one object has the As In my opinion, having Need some thoughts on this @tegefaulkes. |
In the example I gave I figured you could drop the type parameter for one of the messages and still pattern match on that. In that case you'd have to check if the type parameter actually exists which is a little more annoying. So if both messages have the Let's stick with |
Yes, a couple of handlers use this and a couple places in the CLI too. I still think that there could be two success messages. One is the As such, I will make the relevant changes across Polykey's handlers and CLI's relevant commands and tests. |
063e03b
to
6f34a77
Compare
chore: updated tests for mkdir chore: updated mkdir and added tests chore: added warning for untracked directory fix: removed write.yml chore: working on adding non-zero exit codes chore: updated tests to be more accurate chore: addressed review fix: manually updated type of error chore: simplified streaming paths to handler chore: updated polykey version fix: lint fix: updated tests fix: lint
c9b0171
to
97ed38c
Compare
All the tasks have been done in this PR and the CI is also passing. Merging. |
That is good, but why the background so large? And is there a way to scroll the terminal? Also speed up the actual typing. It needs to be done quickly. |
Also the textual resolution looks worse than ascinnema... |
The background is so large so we can crop it to a fitting size later on, as re-rendering it will take some time. There is a way to scroll the terminal. It just used by actual terminal size by default, as I was recording in a vertically split terminal. I can modify the rows and columns in the recording and can change it pretty easily. As for speed, there should definitely be a way to do that. I will have to look into how to get that working though.
Probably because its so zoomed out. I will experiment with settings and upload a functional |
There aren't any actual options to modify the speed. Instead, we can specify the frame delay, which will change the delay between each input/output (a frame) to the specified time in milliseconds. Or, we can change the max idle time, which caps the time between each frame to a limit. The textual resolution being worse than asciinema is a known issue, and something which I (or others) haven't found a solution to. So, as an alternative, I have discovered termsvg, which uses asciinema as its base, records in a slightly modified format, and renders a svg of the terminal with a MacOS-like border. However, while customisation in this is not nearly as extensive as in Terminalizer, and the file format is also difficult to change and modify, it is faster and easier to render than Terminalizer and offers higher image quality. I haven't gotten to updating the GIF yet as my focus has been on #305, but I can do this once the critical and important issues have been closed. |
Description
The current
mkdir
implementation only supports creating a single directory at a time. This needs to be expanded to work similar to UNIX'smkdir
command, which can make multiple directories at the same time, and does not stop when it encounters an error.This PR implements similar features to
secrets mkdir
command, allowing the creation of multiple directories across vaults in a single command.Note: as per Polykey#819 (comment), a warning or notice needs to be sent to
stderr
, warning users that the directory, while it is created, is not part of the source tree and a file must exist within the directory in order for the directory to be detected as a part of the source tree.Issues Fixed
Tasks
secrets mkdir
to align with UNIXmkdir
secrets mkdir
Final checklist