{"id":16226908,"url":"https://github.com/abbychau/diesel_cli_ext","last_synced_at":"2025-04-05T07:05:57.173Z","repository":{"id":52938423,"uuid":"129776280","full_name":"abbychau/diesel_cli_ext","owner":"abbychau","description":"It contains different code generation (not rust codegen) cli tools that may help your life with Diesel easier.","archived":false,"fork":false,"pushed_at":"2024-05-23T07:22:35.000Z","size":123,"stargazers_count":105,"open_issues_count":9,"forks_count":28,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-05-23T07:32:38.098Z","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":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/abbychau.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":"2018-04-16T16:49:32.000Z","updated_at":"2024-05-23T07:22:39.000Z","dependencies_parsed_at":"2024-10-10T12:51:03.661Z","dependency_job_id":"a6730480-687d-489c-ab21-8019e7aa7a80","html_url":"https://github.com/abbychau/diesel_cli_ext","commit_stats":{"total_commits":109,"total_committers":15,"mean_commits":7.266666666666667,"dds":0.6513761467889908,"last_synced_commit":"9c9b725e79f5ece4f32a60b2b15706a3d9cf5b7e"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abbychau%2Fdiesel_cli_ext","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abbychau%2Fdiesel_cli_ext/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abbychau%2Fdiesel_cli_ext/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abbychau%2Fdiesel_cli_ext/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/abbychau","download_url":"https://codeload.github.com/abbychau/diesel_cli_ext/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247299832,"owners_count":20916190,"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-10-10T12:50:59.121Z","updated_at":"2025-04-05T07:05:57.156Z","avatar_url":"https://github.com/abbychau.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Diesel CLI Extension\n\nDiesel CLI Extension is a tool-belt that aids Diesel CLI after it built schema.rs.\n\n[![Build Status](https://travis-ci.org/abbychau/diesel_cli_ext.svg)](https://travis-ci.org/abbychau/diesel_cli_ext)\n[![Crates.io](https://img.shields.io/crates/v/diesel_cli_ext.svg)](https://crates.io/crates/diesel_cli_ext)\n\u003c!-- [![Coverage Status](https://coveralls.io/repos/github/abbychau/diesel_cli_ext/badge.svg?branch=master)](https://coveralls.io/github/abbychau/diesel_cli_ext?branch=master) --\u003e\n\nIt contains 4 functions at this moment.\n1. Generate protobuf file.(`diesel_ext proto`)\n2. Generate model rust structs.(`diesel_ext model`)\n3. Generate conversion implementations.(`diesel_ext into_proto`, and `diesel_ext from_proto`)\n\n## Installation\n`cargo install diesel_cli_ext`\n\n## How to use\nFirst of all, `diesel print-schema \u003e src/schema.rs` \n\nTL;DR: \n\n```\nUsage: target/debug/diesel_ext FILE [options]\n\nCommon Options:\n    -s, --schema-file PATH\n                        Set schema file path\n    -h, --help          Print this help menu\n\nModel Options:\n    -m, --model         Set as model output\n    -M, --map \"FROM_TYPE TO_TYPE\"\n                        Set type mappings (can be set multiple times) e.g.\n                        --map \"BigInt iccc\"\n    -I, --import-types \"TYPE\"\n                        This field adds use statements to the top of every\n                        table! declaration. (can be set multiple times) e.g.\n                        --import_types \"diesel::sql_types::*\"\n        --derive-mod \"TABLENAME MODIFIER\"\n                        (NOT ready)This field adds derives for certain tables.\n                        (can be set multiple times) e.g. --derive-mod\n                        \"table_name +Debug\" --derive-mod \"table_name2 -Debug\"\n    -d, --derive DERIVES\n                        set struct derives\n    -r, --rust_styled_model_fields\n                        set struct field names to be styled according to Rust guidelines\n\nProto Options:\n    -t, --add-table-name \n                        Add #[table_name = x] before structs\n    -p, --proto         Set as proto output\n    -i, --into_proto    Set as into_proto output\n```\n\n(You can see it again by `diesel_ext --help`)\n\nOutput demonstrations are as below...\n\n\n### To generate model structs:\ne.g. `diesel_ext \u003e src/db/db_models.rs` , `diesel_ext -m \u003e src/models.rs`, `diesel_ext --model \u003e src/models.rs` (it is the default option)\n\nSample model output:\n``` rust\nuse chrono::NaiveDateTime;\nuse bigdecimal::BigDecimal;\n\n#[derive(Queryable)]\npub struct CarryOverBalance {\n    pub account_id : i64,\n    pub debit : BigDecimal,\n    pub description : String,\n}\n\n#[derive(Queryable)]\npub struct Order {\n    pub id1 : i64,\n    pub time : NaiveDateTime,\n    pub json : String,\n}\n```\n\n### To generate prelimiting proto file:\n`diesel_ext -p \u003e myproto.proto`, `diesel_ext --proto \u003e myproto.proto`\n\nSample output:\n``` r\nsyntax = \"proto3\";\n\n\nmessage CarryOverBalance {\n    int64 account_id = 1;\n    string debit = 2;\n    string description = 3;\n}\nmessage Order {\n    int64 id1 = 1;\n    string time = 2;\n    string json = 3;\n}\n\n\nmessage EnquireCarryOverBalanceRequest {\n    int64 id =1;\n}\nmessage EnquireOrderRequest {\n    int64 id =1;\n}\n\n\nservice MessageRpc {\n    rpc getCarryOverBalance (EnquireCarryOverBalanceRequest) returns (CarryOverBalance) { }\n    rpc getOrder (EnquireOrderRequest) returns (Order) { }\n}\n```\n\n### To generate proto conversions:\n`diesel_ext -f -c class_name \u003e proto/src/conversion/from_proto.rs`, `diesel_ext -i -c class_name \u003e proto/src/conversion/into_proto.rs`\n\n(if you omit the second parameter, names will be displayed as `_name_` for your search and replace.)\n\nSample output(from):\n``` rust\nuse models;\nuse proto::client_service;\nuse std::str::FromStr;\nuse std::convert::From;\n\nimpl From\u003cclass_name::CarryOverBalance\u003e for models::CarryOverBalance {\n    fn from(i: class_name::CarryOverBalance) -\u003e Self {\n        models::CarryOverBalance{\n            account_id: i.get_account_id(),\n            debit: i.get_debit().to_string(),\n            description: i.get_description().to_string(),\n        }\n    }\n}\n\nimpl From\u003cclass_name::Order\u003e for models::Order {\n    fn from(i: class_name::Order) -\u003e Self {\n        models::Order{\n            id1: i.get_id1(),\n            time: i.get_time().to_string(),\n            json: i.get_json().to_string(),\n        }\n    }\n}\n\n```\n\ninto:\n``` rust\nuse models;\nuse proto::client_service;\nuse std::str::FromStr;\nuse std::convert::From;\n\nimpl From\u003cmodels::CarryOverBalance\u003e for class_name::CarryOverBalance {\n    fn from(i: models::CarryOverBalance) -\u003e Self {\n        let mut o = class_name::CarryOverBalance::new();\n        o.set_account_id(i.account_id.into());\n        o.set_debit(i.debit.to_string());\n        o.set_description(i.description.to_string());\n        o\n    }\n}\n\nimpl From\u003cmodels::Order\u003e for class_name::Order {\n    fn from(i: models::Order) -\u003e Self {\n        let mut o = class_name::Order::new();\n        o.set_id1(i.id1.into());\n        o.set_time(i.time.to_string());\n        o.set_json(i.json.to_string());\n        o\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabbychau%2Fdiesel_cli_ext","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fabbychau%2Fdiesel_cli_ext","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabbychau%2Fdiesel_cli_ext/lists"}