Skip to content

Commit

Permalink
added debug_launch_args example. #10
Browse files Browse the repository at this point in the history
  • Loading branch information
ericsink committed Oct 19, 2022
1 parent eb72b4d commit 7c15f7c
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 0 deletions.
8 changes: 8 additions & 0 deletions examples/debug_launch_args/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "debug_launch_args"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
35 changes: 35 additions & 0 deletions examples/debug_launch_args/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

## How to configure debug launch arguments

Visual Studio's Open Folder mode allows configuring the
arguments for a debugger launch using a `launch.vs.json`
file. This file can be placed in the `.vs` directory,
or, as in this example, as a sibling to `Cargo.toml`.

```
{
"version": "0.2.1",
"defaults": {
},
"configurations": [
{
"type": "default",
"name": "Bin: debug_launch_args/debug_launch_args",
"project": "Cargo.toml",
"projectTarget": "debug_launch_args/debug_launch_args",
"args":
[
"--flag",
"value"
]
}
]
}
```

- `type` must be "default"
- `projectTarget` is the name of the package and the name of the target, separated by a slash
- `project` must be "Cargo.toml"
- `name` must be the same as projectTarget, except with "Bin: " or "Example: ", to indicate what kind of target. Note the space after the colon.
- `args` is a json array of strings, which will be the arguments passed to the executable being debugged

18 changes: 18 additions & 0 deletions examples/debug_launch_args/launch.vs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"version": "0.2.1",
"defaults": {
},
"configurations": [
{
"type": "default",
"name": "Bin: debug_launch_args/debug_launch_args",
"project": "Cargo.toml",
"projectTarget": "debug_launch_args/debug_launch_args",
"args":
[
"--flag",
"value"
]
}
]
}
6 changes: 6 additions & 0 deletions examples/debug_launch_args/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
use std::env;

fn main() {
let args: Vec<String> = env::args().collect();
dbg!(args);
}

0 comments on commit 7c15f7c

Please sign in to comment.