Remove Language Selection from CLI#814
Conversation
WalkthroughLanguage initialization defaults to TypeScript instead of prompting users interactively in the CLI module. Template extraction for Fuel and Evm now uses a fixed TypeScript language constant. New ReScript template configuration and test files are introduced for project scaffolding. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant CLI as CLI Init
participant Config as Init Config
rect rgb(200, 220, 255)
Note over User,CLI: Old Flow
User->>CLI: Start init (no language)
CLI->>CLI: Prompt: Select language
User->>CLI: Respond with choice
CLI->>CLI: Parse selection via FromStr
CLI->>Config: Create config with language
end
rect rgb(200, 255, 220)
Note over User,CLI: New Flow
User->>CLI: Start init (no language)
CLI->>CLI: Default to TypeScript
CLI->>Config: Create config with TypeScript
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
codegenerator/cli/src/template_dirs.rs (2)
288-292: Use proper logging instead of println! for debug output.Debug statements using
println!will always execute and clutter user output. Consider using thelogcrate withdebug!macro ortracingfor structured logging, or remove these statements if they were only needed for temporary debugging.Apply this pattern for proper debug logging:
- println!( - "Getting init template static dir at {}", - template_folder_name - ); - println!("Parent path at {:?}", template_dir.parent_path); + log::debug!( + "Getting init template static dir at {} with parent path {:?}", + template_folder_name, template_dir.parent_path + );
387-387: Use proper logging instead of println! for debug output.Debug statements using
println!will always execute and clutter user output. Consider using thelogcrate withdebug!macro or remove these if temporary.Apply this pattern:
- println!("Generating template for language {}", lang); + log::debug!("Generating template for language {}", lang); let lang_files = self.get_blank_lang_dir(lang).context(format!( "Failed getting static files for blank template with language {}", lang ))?; - println!("language files at {:?}", lang_files.parent_path); + log::debug!("Language files at {:?}", lang_files.parent_path);Also applies to: 393-393
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
codegenerator/cli/src/cli_args/interactive_init/mod.rs(1 hunks)codegenerator/cli/src/executor/init.rs(3 hunks)codegenerator/cli/src/template_dirs.rs(2 hunks)codegenerator/cli/templates/static/blank_template/rescript/rescript.json(1 hunks)codegenerator/cli/templates/static/blank_template/rescript/test/Test.res(1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
codegenerator/cli/**
📄 CodeRabbit inference engine (.cursor/rules/navigation.mdc)
The Rust CLI lives in codegenerator/cli
Files:
codegenerator/cli/src/template_dirs.rscodegenerator/cli/src/cli_args/interactive_init/mod.rscodegenerator/cli/templates/static/blank_template/rescript/rescript.jsoncodegenerator/cli/templates/static/blank_template/rescript/test/Test.rescodegenerator/cli/src/executor/init.rs
codegenerator/cli/templates/static/**/*.res
📄 CodeRabbit inference engine (.cursor/rules/navigation.mdc)
Static templates are raw ReScript files copied verbatim under codegenerator/cli/templates/static
Files:
codegenerator/cli/templates/static/blank_template/rescript/test/Test.res
**/*.res
📄 CodeRabbit inference engine (.cursor/rules/navigation.mdc)
Prefer reading ReScript .res modules directly
Files:
codegenerator/cli/templates/static/blank_template/rescript/test/Test.res
🧠 Learnings (7)
📚 Learning: 2025-10-21T16:31:22.127Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-10-21T16:31:22.127Z
Learning: Applies to codegenerator/cli/src/hbs_templating/codegen_templates.rs : hbs_templating/codegen_templates.rs feeds templates
Applied to files:
codegenerator/cli/src/template_dirs.rscodegenerator/cli/src/executor/init.rs
📚 Learning: 2025-10-21T16:31:22.127Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-10-21T16:31:22.127Z
Learning: Applies to {codegenerator/cli/templates/static/codegen/src/**,codegenerator/cli/templates/dynamic/codegen/src/**} : Template versions of runtime live under templates/{static,dynamic}/codegen/src and are the recommended editing targets
Applied to files:
codegenerator/cli/src/template_dirs.rs
📚 Learning: 2025-10-21T16:31:22.127Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-10-21T16:31:22.127Z
Learning: Applies to codegenerator/cli/** : The Rust CLI lives in codegenerator/cli
Applied to files:
codegenerator/cli/src/template_dirs.rscodegenerator/cli/src/executor/init.rs
📚 Learning: 2025-10-21T16:31:22.127Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-10-21T16:31:22.127Z
Learning: Applies to codegenerator/cli/src/lib.rs : CLI entry point is codegenerator/cli/src/lib.rs
Applied to files:
codegenerator/cli/src/template_dirs.rscodegenerator/cli/src/cli_args/interactive_init/mod.rscodegenerator/cli/src/executor/init.rs
📚 Learning: 2025-10-21T16:31:22.127Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-10-21T16:31:22.127Z
Learning: Applies to codegenerator/cli/templates/static/**/*.res : Static templates are raw ReScript files copied verbatim under codegenerator/cli/templates/static
Applied to files:
codegenerator/cli/src/template_dirs.rscodegenerator/cli/templates/static/blank_template/rescript/rescript.jsoncodegenerator/cli/templates/static/blank_template/rescript/test/Test.res
📚 Learning: 2025-10-21T16:31:22.127Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-10-21T16:31:22.127Z
Learning: Applies to **/*.res : Prefer reading ReScript .res modules directly
Applied to files:
codegenerator/cli/templates/static/blank_template/rescript/rescript.jsoncodegenerator/cli/templates/static/blank_template/rescript/test/Test.res
📚 Learning: 2025-10-21T16:31:22.127Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-10-21T16:31:22.127Z
Learning: Verify tests by running `pnpm rescript` then `pnpm mocha`; use `_only` to focus tests
Applied to files:
codegenerator/cli/templates/static/blank_template/rescript/test/Test.res
🧬 Code graph analysis (1)
codegenerator/cli/src/executor/init.rs (2)
codegenerator/integration_tests/src/main.rs (1)
init_config(73-96)codegenerator/cli/src/cli_args/interactive_init/mod.rs (1)
prompt_missing_init_args(111-192)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build_and_test
🔇 Additional comments (4)
codegenerator/cli/templates/static/blank_template/rescript/test/Test.res (1)
1-3: LGTM! Minimal test template skeleton.This minimal template structure with module imports is appropriate for a ReScript test template that users will extend with their own test cases.
codegenerator/cli/src/executor/init.rs (1)
30-30: LGTM! Necessary mutation for language override.Making
init_configmutable enables the subsequent TypeScript enforcement for template initialization paths.codegenerator/cli/templates/static/blank_template/rescript/rescript.json (1)
1-27: LGTM! Standard ReScript project configuration.The ReScript configuration is well-structured with appropriate compiler settings, source directories, and dependencies for the EnvioIndexer template.
codegenerator/cli/src/cli_args/interactive_init/mod.rs (1)
140-143: LGTM! Clean default to TypeScript.The change from an interactive language selection prompt to defaulting to
Language::TypeScriptaligns with the PR objective of simplifying the CLI by removing the language selection step. Users can still override this for contract imports using the-lflag.
| init_config.language = Language::TypeScript; | ||
|
|
There was a problem hiding this comment.
🧩 Analysis chain
Verify template-only TypeScript enforcement behavior with explicit language flags.
The code forces TypeScript for template paths even if a user explicitly passes -l rescript. This silently overrides the user's choice, which could be confusing.
Please verify:
- Is this the intended behavior when users explicitly pass
-l rescriptto template commands? - Should the CLI provide clearer feedback (warning or error) when a user attempts to use ReScript with templates?
- Does the help text or documentation clarify that templates only support TypeScript?
Run the following script to check if there are any user-facing messages about this limitation:
Also applies to: 59-60
🏁 Script executed:
#!/bin/bash
# Search for help text, error messages, or documentation about template language restrictions
rg -n -C3 'template.*language|language.*template|TypeScript.*only|only.*TypeScript' --type=rustLength of output: 9090
---
🏁 Script executed:
```shell
#!/bin/bash
# Get the context around lines 43-44 and 59-60 in init.rs
sed -n '30,75p' codegenerator/cli/src/executor/init.rs
Length of output: 1902
---
🏁 Script executed:
```shell
#!/bin/bash
# Get more context to see all init flow variants
wc -l codegenerator/cli/src/executor/init.rs
Length of output: 42
🏁 Script executed:
#!/bin/bash
# Extract lines to see all match branches in the execute function
sed -n '1,100p' codegenerator/cli/src/executor/init.rs | grep -n "init_flow\|InitFlow\|Ecosystem::"Length of output: 304
🏁 Script executed:
#!/bin/bash
# Search for all places where language is explicitly set or constrained
rg -n 'language\s*=\s*Language::' codegenerator/cli/src/executor/init.rsLength of output: 119
🏁 Script executed:
#!/bin/bash
# Get the complete init.rs file to understand all init flows
cat codegenerator/cli/src/executor/init.rsLength of output: 11071
🏁 Script executed:
#!/bin/bash
# Search for any help text or CLI args documentation about languages
rg -n 'help|description|doc|--language|-l' codegenerator/cli/src/ --type=rust -B2 -A2 | head -100Length of output: 8201
🏁 Script executed:
#!/bin/bash
# Find and inspect CLI args definitions for InitArgs
fd -name '*.rs' codegenerator/cli/src/cli_args/ --exec grep -l 'InitArgs\|language' {} \;Length of output: 230
🏁 Script executed:
#!/bin/bash
# Look for help/doc attributes on language field in CLI args
rg -n '#\[.*help|#\[.*doc|language.*help' codegenerator/cli/src/cli_args/ --type=rust -B2 -A2Length of output: 0
🏁 Script executed:
#!/bin/bash
# Find InitArgs struct definition
find codegenerator/cli/src/cli_args -name '*.rs' -type fLength of output: 511
🏁 Script executed:
#!/bin/bash
# Search for InitArgs and Language definitions
rg 'struct InitArgs|enum Language' codegenerator/cli/src/ --type=rust -A10Length of output: 1698
---
🏁 Script executed:
```shell
#!/bin/bash
# Get more context around the language field in InitArgs
sed -n '1,80p' codegenerator/cli/src/cli_args/clap_definitions.rs
Length of output: 2547
---
🏁 Script executed:
```shell
#!/bin/bash
# Get the InitArgs struct definition with language field
sed -n '80,150p' codegenerator/cli/src/cli_args/clap_definitions.rs
Length of output: 1868
Address silent TypeScript enforcement in Template init flows
The code forces TypeScript at lines 43 and 59 for Template-based initializations (Fuel and Evm), silently overriding any user-provided language flag (e.g., -l rescript) without warning. This creates an inconsistent user experience, as other init flows (SubgraphID and ContractImport) respect the language choice.
To fix:
- Warn users: Display a message when language is overridden, e.g., "Templates only support TypeScript; switching from ReScript to TypeScript."
- Or enable multi-language support: If template directories exist for other languages, remove the override and pass
&init_config.languageto template extraction methods instead. - Update CLI help: Document that Template init flows only support TypeScript.
🤖 Prompt for AI Agents
In codegenerator/cli/src/executor/init.rs around lines 43 and 59, the init flow
silently forces init_config.language = Language::TypeScript for Template-based
flows which overrides any user-provided -l flag; either (A) add a warning
log/println immediately before the assignment that reports the user-specified
language and states "Templates only support TypeScript; switching from
<UserLang> to TypeScript.", or (B) remove the hard override, instead detect
available template directories for other languages and propagate
&init_config.language into the template extraction calls so templates for other
languages are used if present; finally, update the CLI help/usage text to state
that Template init flows support only TypeScript if you choose option A, or
document multi-language support if you implement option B.
| Ecosystem::Fuel { | ||
| init_flow: init_config::fuel::InitFlow::Template(template), | ||
| } => { | ||
| init_config.language = Language::TypeScript; |
There was a problem hiding this comment.
Instead of mutating init_config I'd prefer passing Language::TypeScript directly as an argument instead of &init_config.language
There was a problem hiding this comment.
As we are using init_config after the match, instead of adding an if statement at the end I thought mutating it would be better.
| @@ -0,0 +1,3 @@ | |||
| open RescriptMocha | |||
There was a problem hiding this comment.
Got it. I was just using code from the previous file.
| lang | ||
| ))?; | ||
|
|
||
| println!("language files at {:?}", lang_files.parent_path); |
There was a problem hiding this comment.
sorry about that, it was for my debugging and forgot to remove.
DZakh
left a comment
There was a problem hiding this comment.
Good 👍 I left a few comments/questions
DZakh
left a comment
There was a problem hiding this comment.
Sorry for introduction to your PR, I've done some fixes by myself. Needed it merged to release 2.32.2 version 🙏
There was a problem hiding this comment.
Actionable comments posted: 0
♻️ Duplicate comments (1)
codegenerator/cli/src/executor/init.rs (1)
57-66: Same template language override applies here.This segment has the same pattern as the Fuel template initialization above.
🧹 Nitpick comments (1)
codegenerator/cli/src/executor/init.rs (1)
43-52: Consider adding a warning when template language preference is overridden to TypeScript.User-provided language preference via
-l rescriptis silently ignored during template initialization (Fuel and EVM templates currently hardcodeLanguage::TypeScript), with no warning message. The CLI help text for the language flag doesn't clarify this restriction. Adding a warning or updating documentation would improve user experience.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
codegenerator/cli/src/executor/init.rs(2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
codegenerator/cli/**
📄 CodeRabbit inference engine (.cursor/rules/navigation.mdc)
The Rust CLI lives in codegenerator/cli
Files:
codegenerator/cli/src/executor/init.rs
🧠 Learnings (3)
📓 Common learnings
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-10-21T16:31:22.127Z
Learning: Applies to codegenerator/cli/templates/static/**/*.res : Static templates are raw ReScript files copied verbatim under codegenerator/cli/templates/static
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-10-21T16:31:22.127Z
Learning: Applies to **/*.res : Prefer reading ReScript .res modules directly
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-10-21T16:31:22.127Z
Learning: Applies to codegenerator/cli/src/hbs_templating/codegen_templates.rs : hbs_templating/codegen_templates.rs feeds templates
📚 Learning: 2025-10-21T16:31:22.127Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-10-21T16:31:22.127Z
Learning: Applies to codegenerator/cli/src/hbs_templating/codegen_templates.rs : hbs_templating/codegen_templates.rs feeds templates
Applied to files:
codegenerator/cli/src/executor/init.rs
📚 Learning: 2025-10-21T16:31:22.127Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-10-21T16:31:22.127Z
Learning: Applies to codegenerator/cli/templates/static/**/*.res : Static templates are raw ReScript files copied verbatim under codegenerator/cli/templates/static
Applied to files:
codegenerator/cli/src/executor/init.rs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build_and_test
CLI now only allows generation of TypeScript projects but you can still use ReScript for contract imports by passing
-l rescriptto the command to override typescript.ref: #790 (review)
also added files required for using rescript for contract import which were removed previously.
Summary by CodeRabbit
New Features
Changes