Skip to main content

Module generate

Module generate 

Source
Expand description

cargo kick g — codegen into an existing kick-rs project.

Currently ships:

  • g module <name> — emit src/modules/<name>/{mod.rs,handlers.rs} and append pub mod <name>; to src/modules/mod.rs.
  • g service <module>/<name> — emit src/modules/<module>/<name>.rs containing a #[service]-derived stub, and append pub mod <name>; to the parent module’s mod.rs.
  • g contributor <module>/<name> — emit src/modules/<module>/<name>.rs containing a #[contributor] async fn + Output struct, and append pub mod <name>; to the parent module’s mod.rs.

Project root is auto-detected by walking up from cwd until we find a directory containing src/modules/mod.rs. That single anchor is what makes us “in a kick-rs project” for the purposes of this command.

Structs§

GenerateContributorArgs
Decoded form of the g contributor subcommand.
GenerateContributorResult
Result of generate_contributor.
GenerateModuleArgs
Decoded form of the g module subcommand.
GenerateModuleResult
Result of generate_module — the directory written + how the main.rs auto-register attempt fared.
GenerateServiceArgs
Decoded form of the g service subcommand.
GenerateServiceResult
Result of generate_service — the file written + auto-register outcome.

Enums§

GenerateError

Functions§

find_project_root
Walk up from start until we find a directory containing src/modules/mod.rs. That’s our project root.
generate_contributor
Run the g contributor <module>/<contributor_snake> flow.
generate_module
Run the g module <name> flow.
generate_service
Run the g service <module>/<service_snake> flow.
to_pascal_case
Convert a snake_case identifier to PascalCase. Used to derive the service struct name from its file name (email_senderEmailSender).
validate_module_name
Module-name validation. Snake-case only — hyphens disallowed because Rust modules can’t have them.