{"id":22079957,"url":"https://github.com/naokim03/rspit","last_synced_at":"2025-03-23T20:43:58.026Z","repository":{"id":63915042,"uuid":"570465811","full_name":"NaokiM03/rspit","owner":"NaokiM03","description":"A command-line tool to run Rust snippet.","archived":false,"fork":false,"pushed_at":"2023-03-10T09:23:11.000Z","size":1133,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-02T00:38:21.757Z","etag":null,"topics":["cargo","cli","command-line","rust","script","tool"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NaokiM03.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-11-25T09:01:43.000Z","updated_at":"2022-11-28T22:16:27.000Z","dependencies_parsed_at":"2024-11-30T23:11:49.783Z","dependency_job_id":"a8aab4d7-c6fd-4733-a738-1b82bc14a163","html_url":"https://github.com/NaokiM03/rspit","commit_stats":{"total_commits":110,"total_committers":2,"mean_commits":55.0,"dds":0.009090909090909038,"last_synced_commit":"55db9b3aa8419bcc0b78a0e022b2adda40adf12f"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NaokiM03%2Frspit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NaokiM03%2Frspit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NaokiM03%2Frspit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NaokiM03%2Frspit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NaokiM03","download_url":"https://codeload.github.com/NaokiM03/rspit/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245168810,"owners_count":20571799,"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","cli","command-line","rust","script","tool"],"created_at":"2024-11-30T23:11:46.382Z","updated_at":"2025-03-23T20:43:58.003Z","avatar_url":"https://github.com/NaokiM03.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PIT\n\nRun Rust snippet containing multiple packages. Embed `Cargo.toml` as a comment to avoid special formatting.\n\n- Run snippet in debug mode\n- Build packages in snippet in release mode and distribute the artifacts to the directory\n- Extract packages in snippet as independent packages\n\nThere is a simple cache system, [as described below](https://github.com/NaokiM03/rspit#note).\n\n![](https://raw.githubusercontent.com/NaokiM03/rspit/c53c405db3acf75ea8ab98d807064d5248379c3d/demo.gif?token=GHSAT0AAAAAABQZZVSH5RNAFETNMJSC4RBMY4FFSXA)\n\n## Motivation\n\n- rust-analyzer supports single file\n\n  - https://github.com/rust-lang/rust-analyzer/issues/6388\n    - https://github.com/rust-lang/rust-analyzer/pull/8955\n  - In such a case, it is not an error even if multiple main functions exist\n\n  \u003cdetails\u003e\n  \u003csummary\u003eSnippet on VSCode\u003c/summary\u003e\n\n  ![](https://raw.githubusercontent.com/NaokiM03/rspit/c53c405db3acf75ea8ab98d807064d5248379c3d/snippet.png?token=GHSAT0AAAAAABQZZVSH3M55TYCHMLZY3LH2Y4FFTQA)\n\n  \u003c/details\u003e\n\n- A large number of packages in one workspace makes rust-analyzer heavy. rust-analyzer's functionality is limited when opening single file, but it is very lightweight\n\n  - However, I believe it has sufficient functionality to write a snippet because it can complement the standard library\n\n  \u003cdetails\u003e\n  \u003csummary\u003erust-analyzer completion\u003c/summary\u003e\n\n  ![](https://raw.githubusercontent.com/NaokiM03/rspit/c53c405db3acf75ea8ab98d807064d5248379c3d/rust-analyzer-completion.png?token=GHSAT0AAAAAABQZZVSGXH67K6XSSWEK3AWAY4FFT5Q)\n\n  \u003c/details\u003e\n\n## Usage\n\n```sh\n$ cargo install rspit\n# omitted\n\n$ cat ./snippet.rs\n//# [package]\n//# name = \"rand\"\n//# version = \"0.1.0\"\n//# edition = \"2021\"\n//#\n//# [dependencies]\n//# rand = \"*\"\n\nuse rand::prelude::*;\n\nfn main() {\n    let num: u64 = random();\n    println!(\"num: {}\", num);\n}\n\n//# ---\n\n//# [package]\n//# name = \"json\"\n//# version = \"0.1.0\"\n//# edition = \"2021\"\n//#\n//# [dependencies]\n//# serde_json = \"*\"\n\nuse serde_json::{Result, Value};\n\nfn main() -\u003e Result\u003c()\u003e {\n    let json = r#\"\n{\n    \"name\": \"Alice\",\n    \"age\": 42\n}\n\"#;\n    let json: Value = serde_json::from_str(json)?;\n    println!(\"name: {}, age: {}\", json[\"name\"], json[\"age\"]);\n\n    Ok(())\n}\n\n$ pit run ./snippet.rs\n# omitted cargo log messages\nRun rand package\nnum: 17349477736480811228\n# omitted cargo log messages\nRun json package\nname: \"Alice\", age: 42\n```\n\n```sh\n$ pit --help\nA command-line tool to run Rust snippet.\n\nUsage: pit [COMMAND]\n\nCommands:\n  check    Check all package in file\n  build    Build all package in file\n  run      Run all package in file\n  release  Build all package in file in release mode and copy the artifacts to the target directory\n  init     Create a new file\n  list     List all packages in the given file\n  add      Add an empty package on top in the given file\n  extract  Extract the package from file\n  clean    Remove everything in the cache directory\n  help     Print this message or the help of the given subcommand(s)\n\nOptions:\n  -h, --help     Print help information\n  -V, --version  Print version information\n```\n\n## Note\n\n- The `target` directory is cached\n- Always build **in debug mode** when `run` and `build` are executed\n- If the source files have not been modified at the time of `run` execution and debug mode artifacts are present, the binary is executed directly without building\n\n## Related projects\n\n- [rust-script](https://github.com/fornwall/rust-script)\n  and the projects listed in the README.\n\n## License\n\nPIT is released under the MIT License\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnaokim03%2Frspit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnaokim03%2Frspit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnaokim03%2Frspit/lists"}