-
Notifications
You must be signed in to change notification settings - Fork 10
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
Command-line argument syntax enhancement suggestion #14
Comments
Thanks very much for proposing the reworked cli arguments and I/O file specs! I'm currently working on it, and have some questions on the specs (though I think these are trivial changes and won't affect when the code will be done).
As a developer, my understanding may be biased with normal users (like the walrus operator), and those questions are just subtle design details. So do please feel free to propose your ideas on the questions, I'd like to choose designs that are aligned with widely used designs in similar tools or scripts, which I think you know better than me :) |
Thank you for your work! And for even mentioning me in the commit! As if I actually did anything… I did not, it's all your hard work. I really appreciate it. I'm sorry for the late reply. I've been spending all my free time working on another project, which I've only just completed, more or less. 1.
|
Updated 2023-11-18: All issues fixed and the source is at: https://github.com/GeographicCone/UefiVarTool as a fork with many other changes. I really appreciate everything you did, I hope the credit I gave you as the original author is appropriate. I also made you a co-author on the initial commit. I'd be glad to resume the discussion if you ever get the time but meanwhile, the immediate problem I had is solved, and the solution to it is available to everyone. So this is just a heads-up my original comment below can be disregarded now, although I'm still leaving it for reference: I'm trying to use the new I wanted to ask if it's completed as is, or is it work in progress. The reason I ask is it doesn't really seem to work out of the box for me. But then maybe it's my setup or environment (for the record, it's Shell v2.2 from 1. When passed command-line arguments, it'd for some reason try to parse its own name as an argument and fail. Looking at the code, I found the culprit at src/args.rs:236 in drop_first_arg() where it's treating the first argument as an option to parse, unless it ends with I'm not really sure about the use case when argv[0] (or whatever the Rust equivalent for that is) should be parsed as an argument: I'd have expected it'd always be the process's own name, but in any case, in my opinion it shouldn't make the assumption that it is not unless it has that extension. At the very least I think it should also check its own basename (w/o extension) and possibly also the aliases. In my compiled version I've changed that from the default 2. It doesn't care about
Error parsing input file:
Unexpected value: Similarly, with: Error parsing input file:
Unexpected value: [Unprintable Character] The unprintable character is likely the The different Setup:0x1 Setup:0x1=0x1 As well as the following, to exclude the case when the #
Setup:0x1 #
Setup:0x1=0x1 The error messages were the same in all scenarios. The file format was I also tried piping in the input: echo Setup:0x1 | setup_var.efi
echo Setup:0x1 |a setup_var.efi
echo Setup:0x1=0x1 | setup_var.efi
echo Setup:0x1=0x1 |a setup_var.efi Here there is no output at all, no error message – with the version I modified, otherwise it just shows usage information in all these cases. In the first step, the problem seems to be that for 3. While it does work with both querying and assignment, even with multiple arguments, it doesn't seem to be able handle size specification. For example: setup_var.efi Setup:0x1(2)
Error parsing arguments:
Unexpected value: Setup:0x1(2): Unexpected value: 2) The results are similar for The culprit is somewhere in parse_value_arg() in src/args.rs:437 but I stopped looking to ask this question, partly because it's difficult for me to tell what exactly is going on there: maybe it's because I'm not proficient in Rust but what also doesn't help is that there are 20+ locations where I see you have tests for all those things that are not working for me. So I guess they are working for you? I'm not familiar with Rust. Maybe it's down to the toolchain I'm using?
I really don't understand how come I am running into so many issues with this, considering the code looks complete. I'd like to get the new version working now that you wrote it, and made it available. I'm not expecting support or anything but if I were to fix this myself I think it'd end up with a major rewrite, which isn't really what I've been aiming for. So I wanted to ask first:
Thank you. |
Thank you for your work. The tool runs great for me with no bugs. This is just an enhancement suggestion for consideration. There are two very minor things I noticed:
-w
had to be prepended before the value to be written (i.e. no-w
, no write).-s 0x2
instead of even just-s 2
is mildly annoying.This however got me thinking how the command-line arguments could be rethought in general. What if the syntax were instead:
setup_var.efi [VarStoreName:]<Offset>[(Size)][=NewValue]
For example:
setup_var.efi 0x0CA9
Read a byte at offset0x0CA9
fromSetup
(backward-compatible)setup_var.efi SaSetup:0x0F(2)
Read a word (two bytes) at offset0x0F
fromSaSetup
setup_var.efi AMITSESetup:0x40=0x01
Write0x01
toAMITSESetup
at offset0x40
This would have the added benefit that the tool could iterate through multiple white space-separated commands in one go:
setup_var.efi SaSetup:0x018D=0x01 SaSetup:0x05=0x01 SaSetup:0x06=0x30 SaSetup:0x0F(2)=0x1250
It's not a contrived example. On the laptop I have, the above sets the memory profile to Custom, reference clock to 100MHz, ratio to ×48, and Refresh Time (tREFI) to 4688.
And in the future, multiple commands could also be read from a file, for example:
setup_var.efi < my_tweaks.txt
While in an even more distant future, where variables could be set and referenced, the said file could look:
I think this would make it slightly more convenient to use (not that it isn't now), and a bit less prone to user error.
Of course I realize it's your project and your time. It's great as it is, and thank you for making it available. This is just food for thought. Hope you don't mind my sharing this idea.
Edit: There's one other thing I forgot to mention. With the above argument structure, the output from the program could be exactly in the same format that it would also accept back as the input, for example:
This way it could be easily saved to a file:
setup_var.efi SaSetup:0x018D SaSetup:0x05 SaSetup:0x06 SaSetup:0x0F(2) > my_defaults.txt
And then restored:
setup_var.efi < my_defaults.txt
The text was updated successfully, but these errors were encountered: