-
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
Upgrade to clap4, add extra args and help strings #26
Upgrade to clap4, add extra args and help strings #26
Conversation
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.
Overall looks like an improvement!
I haven't gotten to look at the general changes for Clap4 but out of curiosity does the |
Not quite –
and both However, the combination of $ cargo 3ds test --foo --no-run -- bar
[src/main.rs:14] &input = Input {
cmd: Test(
Test {
no_run: false,
run_args: Run {
address: None,
argv0: None,
server: false,
retries: None,
},
},
),
dry_run: false,
cargo_options: [
"--foo",
"--no-run",
"--",
"bar",
],
}
[src/main.rs:15] input.cargo_opts() = [
"--foo",
"--no-run",
"--",
]
[src/main.rs:16] input.exe_args() = [
"bar",
] I thought that behavior might be more confusing than having to pass the extra I just found that there is also |
Also add the most basic `debug_assert` test.
Ok, I've pushed a set of changes that hooks everything up, and I tested a variety of flag combinations manually as well as added a couple unit tests on the custom parsing logic. Here's an example of running it with the 3dslink args (one slightly awkward caveat is that 3dslink args must always come before cargo args, which I suppose might be worth documenting somewhere): $ cargo 3ds run --server --address 192.168.0.167 --example output-3dslink
[snip]
Getting metadata
Building smdh:/Users/ianchamberlain/Documents/Development/3ds/ctru-rs/target/armv6k-nintendo-3ds/debug/examples/output-3dslink.smdh
Building 3dsx: /Users/ianchamberlain/Documents/Development/3ds/ctru-rs/target/armv6k-nintendo-3ds/debug/examples/output-3dslink.3dsx
Adding RomFS from /Users/ianchamberlain/Documents/Development/3ds/ctru-rs/ctru-rs/examples/romfs
Running 3dslink
Sending output-3dslink.3dsx, 1695260 bytes
497493 sent (29.35%), 39 blocks
starting server
server active ...
Hello 3dslink!
Press Start on the device to disconnect and exit.
exiting ... I also verified There may be some weird edge cases missing here but hopefully some additional testing and actually using the tool could catch those, so I think this is ready for review and we can always come back and bugfix stuff later. |
|
||
impl Run { | ||
/// Get the args to pass to `3dslink` based on these options. | ||
pub fn get_3dslink_args(&self) -> Vec<String> { |
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.
Do you want to add tests for this? Not needed for the merge at least.
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.
Sure, I can add it whenever I try to add CI / other test assertions in a future PR
This is exactly what I had in mind for this tool! Thank you so much for the work done. |
Addresses #13
Leaving this as draft because I want to get some opinions first, but basically with Clap 4 there are some changes which should make it work a lot nicer to pass trailing varargs to
cargo
. This builds off the work @SteveCookTU did to update the CLI and allows us to expose the3dslink
args mentioned in the issue linked above.Example help text
Dump of debug output when varargs are passed
Let me know what y'all think, and if it seems good I'll go ahead and wire up the command parser into the actual logic. After / with this change I was also thinking of adding some CLI tests with
trycmd
or something like that which could print the commands that the tool would run, although it will probably take a bit of mocking and stuff to get that working.