Skip to main content

handle_smart_init_with

Function handle_smart_init_with 

Source
pub fn handle_smart_init_with<R: ConfigEnvironment>(
    template_arg: Option<&str>,
    force: bool,
    colors: Colors,
    env: &R,
) -> Result<bool>
Expand description

Handle the smart --init flag with a custom path resolver.

This function intelligently determines what the user wants to initialize:

  • If a value is provided and matches a known template name -> create PROMPT.md
  • If config doesn’t exist and no template specified -> create config
  • If config exists but PROMPT.md doesn’t -> prompt to create PROMPT.md
  • If both exist -> show helpful message about what’s already set up

§Arguments

  • template_arg - Optional template name from --init=TEMPLATE
  • force - If true, overwrite existing PROMPT.md without prompting
  • colors - Terminal color configuration for output
  • env - Path resolver for determining config file locations

§Returns

Returns Ok(true) if the flag was handled (program should exit after), or Ok(false) if not handled, or an error if initialization failed.

§Errors

Returns error if the operation fails.