{"id":19949472,"url":"https://github.com/cbourjau/cargo-with","last_synced_at":"2025-05-03T18:32:39.138Z","repository":{"id":49346758,"uuid":"154731570","full_name":"cbourjau/cargo-with","owner":"cbourjau","description":"A third-party cargo extension to run the build artifacts through tools like `gdb`","archived":false,"fork":false,"pushed_at":"2019-12-19T03:12:12.000Z","size":90,"stargazers_count":72,"open_issues_count":2,"forks_count":4,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-10-28T22:12:15.086Z","etag":null,"topics":["cargo-subcommand","debugging","rust"],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cbourjau.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-10-25T20:13:45.000Z","updated_at":"2024-03-15T22:26:14.000Z","dependencies_parsed_at":"2022-09-26T20:10:31.465Z","dependency_job_id":null,"html_url":"https://github.com/cbourjau/cargo-with","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cbourjau%2Fcargo-with","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cbourjau%2Fcargo-with/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cbourjau%2Fcargo-with/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cbourjau%2Fcargo-with/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cbourjau","download_url":"https://codeload.github.com/cbourjau/cargo-with/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224370110,"owners_count":17299968,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cargo-subcommand","debugging","rust"],"created_at":"2024-11-13T00:45:22.525Z","updated_at":"2024-11-13T00:45:23.060Z","avatar_url":"https://github.com/cbourjau.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"cargo-with\n==========\n`cargo-with` is a cargo-subcommand making it easy to run the build artifacts produced by `cargo run`, `cargo build` or `cargo bench` through other tools such as `gdb`, `strace`, `valgrind`, `rr`, or whatever else you may come up with.\n\n[![Build Status](https://travis-ci.org/cbourjau/cargo-with.svg)](https://travis-ci.org/cbourjau/cargo-with)\n[![crates.io](https://img.shields.io/crates/v/cargo-with.svg)](https://crates.io/crates/cargo-with)\n\n\nInstallation\n-----------\nInstall with the usual `cargo install` magic:\n```shell\ncargo install cargo-with\n```\nUsage\n-----\nThe core idea of `cargo-with` is to fit well into your development workflow using `cargo \u003csubcommand\u003e`.\nAll you have to do is add `with \u003csome-command\u003e -- ` in front of your usual `cargo` commands. `cargo-with` will then try it's best to identify the created artifact and run it with your command.\n\nE.g. in order to run your binary through `gdb` do:\n\n```shell\ncargo with gdb -- run\n```\n\nThis will firstly build the binary using `cargo build`, and then run `gdb {bin} {args}`, where `{bin}` is the path to the produced artifact and `{args}` is the arguments provided to cargo after the last `--` (in this case none).\n\n\n### Moving arguments around\n\nInstead of implicitly appending the artifact path and arguments to the provided command, you could also use placeholders to tell `cargo-with` where to place them. This can be done by using `{bin}` and `{args}` in the provided command.\n\n```\ncargo with \"echo {args} {bin}\" -- run -- --argument1 --argument2\n```\n\nI the above command, `{bin}` will be replaced by the path to the built artifact while `{args}` will be replaced by `--argument1 --argument2`.\n\n### Disambiguating multiple binaries\n\nThere are often mulitiple candiate artifacts when cargo builds your project, especially when building tests. Therefore `cargo-with` may in some situations need more information to select your preferred candidate. This is done via explicitly specificing to cargo which artifact to build through the use of `--bin \u003cname-of-binary\u003e`, `--example \u003cname-of-example\u003e`, `--lib \u003cname-of-lib\u003e`* or `--test \u003cname-of-unit-test\u003e`*.\n\n```\ncargo with \"gdb --args {bin} {args}\" -- test --bin my-app\ncargo with \"gdb --args {bin} {args}\" -- test --lib my-library\ncargo with \"gdb --args {bin} {args}\" -- test --test my-unit-test\ncargo with \"gdb --args {bin} {args}\" -- test --example my-example\n```\n\n*Only avaliable when using `cargo test`\n\n### Examining tests\n\nCargo will run tests in parallel, hence running `cargo with gdb -- test --lib my-library` is probably not what you want. You can examine a single test by giving the name of the test function to cargo; `cargo with gdb -- test --lib my-library my_test_function_name`.\n\nNote about `cargo run`\n----------------------\nIn the case of `cargo run` `cargo-with` does replace `run` with `build` implicitly in order to avoid execution of\nthe binary after compilation.\n\nFuture of this crate\n--------------------\nThere are currently [open issues](https://github.com/rust-lang/cargo/issues/3670) upstream in cargo which might make this crate redundant in the future.\n\nContributors\n------------\nThis crate would not be what it is today without the many contributions by [@barskern](https://github.com/barskern)!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcbourjau%2Fcargo-with","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcbourjau%2Fcargo-with","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcbourjau%2Fcargo-with/lists"}