{"id":13998160,"url":"https://github.com/recmo/cli-batteries","last_synced_at":"2025-04-14T19:06:52.590Z","repository":{"id":37356968,"uuid":"494869727","full_name":"recmo/cli-batteries","owner":"recmo","description":"Batteries included command line interfaces.","archived":false,"fork":false,"pushed_at":"2023-07-18T08:15:59.000Z","size":322,"stargazers_count":22,"open_issues_count":17,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-14T19:06:36.887Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/recmo.png","metadata":{"files":{"readme":"Readme.md","changelog":"Changelog.md","contributing":null,"funding":null,"license":"mit-license.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-05-21T18:54:30.000Z","updated_at":"2024-10-04T08:53:25.000Z","dependencies_parsed_at":"2024-10-23T06:25:31.387Z","dependency_job_id":"19d59aad-dd53-4a73-b335-3182f24ca7ef","html_url":"https://github.com/recmo/cli-batteries","commit_stats":{"total_commits":110,"total_committers":4,"mean_commits":27.5,"dds":"0.036363636363636376","last_synced_commit":"fad6ac88452dbe827d2e14fba2488320a87b1c1f"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/recmo%2Fcli-batteries","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/recmo%2Fcli-batteries/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/recmo%2Fcli-batteries/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/recmo%2Fcli-batteries/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/recmo","download_url":"https://codeload.github.com/recmo/cli-batteries/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248943456,"owners_count":21186958,"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":[],"created_at":"2024-08-09T19:01:26.226Z","updated_at":"2025-04-14T19:06:52.571Z","avatar_url":"https://github.com/recmo.png","language":"Rust","readme":"# CLI Batteries\n\n[![crates.io](https://buildstats.info/crate/cli-batteries)](https://crates.io/crates/cli-batteries)\n[![docs.rs](https://img.shields.io/docsrs/cli-batteries)](https://docs.rs/cli-batteries)\n[![MIT License](https://img.shields.io/github/license/recmo/cli-batteries)](https://github.com/recmo/cli-batteries/blob/main/mit-license.md)\n[![dependency status](https://deps.rs/repo/github/recmo/cli-batteries/status.svg)](https://deps.rs/repo/github/recmo/cli-batteries)\n[![codecov](https://codecov.io/gh/recmo/cli-batteries/branch/main/graph/badge.svg?token=WBPZ9U4TTO)](https://codecov.io/gh/recmo/cli-batteries)\n[![CI](https://github.com/recmo/cli-batteries/actions/workflows/ci.yml/badge.svg)](https://github.com/recmo/cli-batteries/actions/workflows/ci.yml)\n\nOpinionated batteries-included command line interface runtime utilities.\n\nTo use it, add it to your `Cargo.toml`\n\n```toml\n[dependencies]\ncli-batteries = \"0.1\"\n\n[build-dependencies]\ncli-batteries = \"0.1\"\n```\n\nand call the [`build_rs`] function in your `build.rs`\n\n```rust,ignore\nfn main() {\n    cli_batteries::build_rs().unwrap()\n}\n```\n\nThen in your `src/main.rs` you define app specific command line arguments using [`clap::Parser`][clap] and run the app as follows\n\n```rust,ignore\nuse cli_batteries::{version, Parser};\nuse std::{path::PathBuf, io::Result};\nuse tokio::fs::File;\n\n#[derive(Parser)]\n#[group(skip)]\nstruct Options {\n    /// File to read\n    #[clap(long, env, default_value = \"Readme.md\")]\n    file: PathBuf,\n}\n\nasync fn app(options: Options) -\u003e Result\u003c()\u003e {\n    let mut file = File::open(options.file).await?;\n    Ok(())\n}\n\nfn main() {\n    cli_batteries::run(version!(), app);\n}\n```\n\nYou can see this working in the [example project](./example).\n\n## Features\n\n* `signals`: Handle Ctrl-C, SIGINT and SIGTERM with gracefull shutdown.\n* `mimalloc`: Use the [mimalloc] allocator with security hardening features enabled.\n* `rand`: Log and configure random seeds.\n* `rayon`: Log and configure number of threads.\n* `prometheus`: Start a Prometheus metrics server.\n* `metered-allocator`: Collect metric on memory allocation, enables `prometheus`.\n* `mock-shutdown`: Enable the `reset_shutdown` function that allows re-arming shutdown for testing.\n* `tokio-console`: Enable the `--tokio-console` option to start a Tokio console server on `http://127.0.0.1:6669/` for async inspection.\n* `otlp`: Enable the `--trace-otlp` option to push traces to an OpenTelementry collector.\n\n[mimalloc]: https://github.com/microsoft/mimalloc\n\n\n## Building and testing\n\nFormat, lint, build and test everything (I recommend creating a shell alias for this):\n\n```sh\ncargo fmt \u0026\u0026\\\ncargo clippy --all-features --all-targets \u0026\u0026\\\ncargo test --workspace --all-features --doc -- --nocapture \u0026\u0026\\\ncargo test --workspace --all-features --all-targets -- --nocapture \u0026\u0026\\\ncargo doc --workspace --all-features --no-deps\n```\n\nCheck documentation coverage\n\n```sh\nRUSTDOCFLAGS=\"-Z unstable-options --show-coverage\"  cargo doc --workspace --all-features --no-deps\n```\n\n## To do\n\nGoals:\n\nMaybe:\n\n---\n\n[![lines of code](https://img.shields.io/tokei/lines/github/recmo/cli-batteries)](https://github.com/recmo/cli-batteries)\n[![GitHub contributors](https://img.shields.io/github/contributors/recmo/cli-batteries)](https://github.com/recmo/cli-batteries/graphs/contributors)\n[![GitHub issues](https://img.shields.io/github/issues/recmo/cli-batteries)](https://github.com/recmo/cli-batteries/issues)\n[![GitHub pull requests](https://img.shields.io/github/issues-pr/recmo/cli-batteries?label=PRs)](https://github.com/recmo/cli-batteries/pulls)\n[![GitHub Repo stars](https://img.shields.io/github/stars/recmo/cli-batteries)](https://star-history.com/#recmo/cli-batteries\u0026Date)\n[![crates.io](https://img.shields.io/crates/d/cli-batteries)](https://crates.io/crates/cli-batteries)\n","funding_links":[],"categories":["Rust"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frecmo%2Fcli-batteries","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frecmo%2Fcli-batteries","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frecmo%2Fcli-batteries/lists"}