{"id":20673708,"url":"https://github.com/cpg314/cargo-group-imports","last_synced_at":"2025-10-11T05:10:11.953Z","repository":{"id":200409547,"uuid":"705187593","full_name":"cpg314/cargo-group-imports","owner":"cpg314","description":"Group imports in Rust workspaces","archived":false,"fork":false,"pushed_at":"2025-02-26T07:55:25.000Z","size":91,"stargazers_count":1,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-29T01:55:21.949Z","etag":null,"topics":["cargo","formatter","linter","rust"],"latest_commit_sha":null,"homepage":"https://c.pgdm.ch/code","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cpg314.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2023-10-15T09:50:08.000Z","updated_at":"2025-02-26T07:55:29.000Z","dependencies_parsed_at":"2024-01-01T15:22:39.126Z","dependency_job_id":"67face38-378a-48a9-9f9f-729b033e6b68","html_url":"https://github.com/cpg314/cargo-group-imports","commit_stats":null,"previous_names":["cpg314/cargo-group-imports"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/cpg314/cargo-group-imports","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cpg314%2Fcargo-group-imports","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cpg314%2Fcargo-group-imports/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cpg314%2Fcargo-group-imports/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cpg314%2Fcargo-group-imports/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cpg314","download_url":"https://codeload.github.com/cpg314/cargo-group-imports/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cpg314%2Fcargo-group-imports/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279006349,"owners_count":26084084,"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","status":"online","status_checked_at":"2025-10-11T02:00:06.511Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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","formatter","linter","rust"],"created_at":"2024-11-16T20:42:19.701Z","updated_at":"2025-10-11T05:10:11.913Z","avatar_url":"https://github.com/cpg314.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cargo-group-imports\n\nGroup imports in workspace source files as:\n\n1. Module imports and declarations\n2. Standard library\n3. External crates\n4. Workspace crates\n5. Crate modules\n\nFor example (see also the before/after files in `test-data`):\n\n```rust\nmod module;\nuse module::Client;\n\nuse std::sync::Arc;\n\nuse tokio::sync::Mutex;\n\nuse other_crate::Flags;\n\nuse crate::Options;\n\n```\n\nThis roughly corresponds to the [`group_imports` unstable rustfmt option](https://rust-lang.github.io/rustfmt/?version=v1.4.38\u0026search=#group_imports), with the difference\nthat `rustfmt` does not distinguish workspace crates from external ones.\n\n### Tests and binaries\n\nFor the purpose of grouping imports, test and binaries are considered to be in the same crate, although they technically are different crates. This can for example result in the following grouping:\n\n```rust\nuse anyhow::Context;\n\nuse mycrate::**; // the binary belongs to `mycrate`.\nuse crate::test_utils;\n```\n\nThis is driven by implementation simplicity rather than a true design choice.\n\n## Installation\n\n```console\n$ cargo install --git https://github.com/cpg314/cargo-group-imports\n```\n\nAlternatively, see the binaries on the [Releases](https://github.com/cpg314/cargo-group-imports/releases) page.\n\n## Usage\n\n```\ncargo group-imports [OPTIONS] [WORKSPACE]\n\nArguments:\n  [WORKSPACE]  [default: current folder]\n\nOptions:\n      --fix            Apply changes\n      --color \u003cCOLOR\u003e  [default: auto] [possible values: auto, always, never]\n  -h, --help           Print help\n  -V, --version        Print version\n```\n\nBy default, the tool checks that the imports are correctly grouped and displays a diff otherwise. The `--fix` flag applies the necessary changes, if any. This matches the behaviour of `cargo clippy`.\n\n![Screenshot](screenshot.png)\n\n```console\n$ cargo group-imports\n$ cargo group-imports --fix\n```\n\nThe return code is `0` when no changes are necessary, `1` otherwise. This can be used in CI checks.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcpg314%2Fcargo-group-imports","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcpg314%2Fcargo-group-imports","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcpg314%2Fcargo-group-imports/lists"}