-
Notifications
You must be signed in to change notification settings - Fork 2
Adding 'overwrite', 'name-in-archive' and 'dir-in-archive' arguments to the add command #115
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
base: main
Are you sure you want to change the base?
Adding 'overwrite', 'name-in-archive' and 'dir-in-archive' arguments to the add command #115
Conversation
|
I would actually argue that the |
8e23498 to
a64d52d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry it took so long for me to look at this PR. I add a couple comments. All looks good, and only problem I have with the addition is the argument names. I added a couple options, but think that -f,--file and -p,--path might be the best (easiest to read/understand) option. Also, thank you for adding more tests for this - amazing 🥇
EDIT: Maybe -f,--filename might be better
src/main.cpp
Outdated
| add->add_option("-p,--path", basePath, "Path within MPQ archive"); | ||
| add->add_option("--dir-in-archive", baseDirInArchive, "Directory to put file inside within MPQ archive"); | ||
| add->add_option("--name-in-archive", baseNameInArchive, "Filename inside MPQ archive"); | ||
| add->add_flag("--overwrite", addOverwrite, "Overwrite file if it already is in MPQ archive"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please add in -o as a short option. Would be nice if every argument had a short option
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm happy to add it. The reason I did not is because -o is used as short option for --output in the subcommands extract and create. While this is for the add subcommand - so it should be unambiguous - I still figured it could be confusing to have the same option mean different things in different contexts.
If you think it might be problematic to have -o mean multiple things, we could maybe use -w as short hand for --overwrite? If not, I'm happy to add -o here too -- I have no strong feelings about it :)
Let me know what you prefer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added -w as a short option for overwrite (see my above comment as to why). Let me know if you prefer -o instead.
README.md
Outdated
| mpqcli add fta.txt wow-patch.mpq --path <path/in/archive> | ||
| $ echo "For The Alliance" > fta.txt | ||
| $ mpqcli add fta.txt wow-patch.mpq --name-in-archive "texts\\alliance.txt" | ||
| [+] Adding file: texts\alliance.txt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmmm.... I am both sides of the fence about adding $ to indicate a prompt (when a command is being run). It makes an example like this much easier to read (two lines of commands)... But makes it harder to copy paste. Maybe the better solution would be:
echo "For The Alliance" > fta.txt; mpqcli add fta.txt wow-patch.mpq --name-in-archive "texts\\alliance.txt"
[+] Adding file: texts\alliance.txt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anyway - no big deal about this one. Feel free to leave or change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the examples mix commands and their output, I figured it would be good to make it clear what is what. I suppose that by chaining commands and thus making it a one liner, it does become pretty clear, but readability suffers.
I'd keep the $ , but this is very minor, and I don't mind either way.
src/main.cpp
Outdated
| ->check(CLI::ExistingFile); | ||
| add->add_option("-p,--path", basePath, "Path within MPQ archive"); | ||
| add->add_option("--dir-in-archive", baseDirInArchive, "Directory to put file inside within MPQ archive"); | ||
| add->add_option("--name-in-archive", baseNameInArchive, "Filename inside MPQ archive"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure about the argument naming here. I have no problem with the logic (implemented below). But the long command arguments are a little unwieldy.
Was thinking archive-name and archive-path, but these are confusing - as people may think that is the actual MPQ archive name/path.
Maybe path and name would be simple?
mpqcli add -p path/in/archive -f filename-in-archive.exe targetfile.exe target.mpq
This might work, as the actual local file to add is a positional argument (so -f and --file is not used). I am not sure, this might also be confusing to users, but is the best one I could come up with.
Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with you that the long command arguments are a little unwieldy. But like you also say, it's difficult to find good shorter names that are not potentially unclear. I find archive-name and archive-path downright confusing, and path and name (or filename) rather non-descriptive.
My take would be this:
- Remove
path/dir-in-archive, since the same can be accomplished by thename-in-archiveparameter. Removing it keeps the interface simpler. - Keep the
name-in-archivename even though its longer than ideal. - Add a short option
-n(or-f) forname-in-archive. This way it's convenient to use it, even though the long argument name is unwieldy.
These are my recommendations. However, I'm not very vested in the naming here, and I'm happy to let you have the final say in what to name the arguments, their short options, and whether to keep or remove path / dir-in-archive.
Thank you, happy you like it. I gave my thoughts on the argument naming in the comments above.
|
41dd245 to
3f9251e
Compare
…to the add command
3f9251e to
91dbc30
Compare
|
@thomaslaurenson : I fixed the merge conflicts (both here and in #116). Both PRs are pretty much identical to before. Let me know what you think about the naming of parameters, and whether or not to keep |
|
I'd prefer to keep the path command so I don't have to construct the path and append the filename to said path for any file I'd add to a specific directory :) |
I understand its usefulness, but something like either of these would accomplish the same, while hardly being heavier on the user:
This is arguably somewhat more cumbersome for the user, but the readme says it "is a command-line tool, designed for automation", and it is "designed to work seamlessly with other command-line tools, supporting piping, redirection, and integration into shell scripts and workflows". In my mind, that means the |
From an end user perspective I'd personally say that keeping the path and name in archive separate is more intuitive than having a combined option where the end user has to construct the final path + filename, even if that is how MPQs handle files internally. I think it is better to handle the merging of the filename and the path internally in the tool, rather than having to do so externally. It's a nice abstraction with clear delineation, and allows for some more granularity, but either way I'm happy with the option to specify the name of the file! |
The
addcommand now accepts these arguments:overwrite- if set to true, an existing file inside the MPQ will be overwritten.name-in-archive- the complete filename of the added file inside the MPQ.dir-in-archive- the directory name to place the file under inside the MPQ. Previously calledpath. I find it clearer to rename the argument todir-in-archivesince that is what it is, and the Readme clearly states that things might change until v1.0.0.In addition, I refactored the tests for the add command and corrected a previous test that didn't do what it was supposed to.