Skip to content

Remove Language Selection from CLI#814

Merged
DZakh merged 3 commits into
mainfrom
nb/remove-lang-selection
Nov 7, 2025
Merged

Remove Language Selection from CLI#814
DZakh merged 3 commits into
mainfrom
nb/remove-lang-selection

Conversation

@nikbhintade

@nikbhintade nikbhintade commented Nov 7, 2025

Copy link
Copy Markdown
Member

CLI now only allows generation of TypeScript projects but you can still use ReScript for contract imports by passing -l rescript to 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

    • Added ReScript template support, including project configuration and test file templates for new ReScript projects.
  • Changes

    • TypeScript is now the default language during interactive initialization; language selection prompt has been removed.

@nikbhintade nikbhintade requested a review from DZakh November 7, 2025 09:07
@coderabbitai

coderabbitai Bot commented Nov 7, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

Language 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

Cohort / File(s) Summary
CLI language initialization defaults
codegenerator/cli/src/cli_args/interactive_init/mod.rs, codegenerator/cli/src/executor/init.rs
Removes interactive language selection prompt from None branch, defaulting to Language::TypeScript. Fuel and Evm template initialization fixed to use TypeScript. Removes FromStr dependency and simplifies error context messages.
ReScript template addition
codegenerator/cli/templates/static/blank_template/rescript/rescript.json, codegenerator/cli/templates/static/blank_template/rescript/test/Test.res
Introduces ReScript project configuration with module system, JSX, dependencies (generated, envio, rescript-schema), and minimal test template skeleton with RescriptMocha, Belt, and TestHelpers imports.

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
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Areas requiring attention:
    • Verify that defaulting to TypeScript is intentional and doesn't break existing workflows expecting user selection
    • Confirm that Fuel and Evm templates are the only endpoints requiring the hardcoded TypeScript fix
    • Check that removing FromStr import doesn't affect other language parsing logic elsewhere in the module

Poem

🐰 TypeScript now the default way,
No prompts for users today!
ReScript templates join the fold,
New configs, stories yet untold. 🚀

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: removing language selection from the CLI to default to TypeScript, which is the primary modification across all changed files.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch nb/remove-lang-selection

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 the log crate with debug! macro or tracing for 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 the log crate with debug! 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

📥 Commits

Reviewing files that changed from the base of the PR and between 2ffff06 and 75e08c3.

📒 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.rs
  • codegenerator/cli/src/cli_args/interactive_init/mod.rs
  • codegenerator/cli/templates/static/blank_template/rescript/rescript.json
  • codegenerator/cli/templates/static/blank_template/rescript/test/Test.res
  • codegenerator/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.rs
  • 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/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.rs
  • 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/src/lib.rs : CLI entry point is codegenerator/cli/src/lib.rs

Applied to files:

  • codegenerator/cli/src/template_dirs.rs
  • codegenerator/cli/src/cli_args/interactive_init/mod.rs
  • 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/template_dirs.rs
  • codegenerator/cli/templates/static/blank_template/rescript/rescript.json
  • codegenerator/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.json
  • codegenerator/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_config mutable 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::TypeScript aligns with the PR objective of simplifying the CLI by removing the language selection step. Users can still override this for contract imports using the -l flag.

Comment thread codegenerator/cli/src/executor/init.rs Outdated
Comment on lines +43 to +44
init_config.language = Language::TypeScript;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 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:

  1. Is this the intended behavior when users explicitly pass -l rescript to template commands?
  2. Should the CLI provide clearer feedback (warning or error) when a user attempts to use ReScript with templates?
  3. 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=rust

Length 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.rs

Length of output: 119





🏁 Script executed:

#!/bin/bash
# Get the complete init.rs file to understand all init flows
cat codegenerator/cli/src/executor/init.rs

Length 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 -100

Length 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 -A2

Length of output: 0





🏁 Script executed:

#!/bin/bash
# Find InitArgs struct definition
find codegenerator/cli/src/cli_args -name '*.rs' -type f

Length of output: 511


🏁 Script executed:

#!/bin/bash
# Search for InitArgs and Language definitions
rg 'struct InitArgs|enum Language' codegenerator/cli/src/ --type=rust -A10

Length 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:

  1. Warn users: Display a message when language is overridden, e.g., "Templates only support TypeScript; switching from ReScript to TypeScript."
  2. Or enable multi-language support: If template directories exist for other languages, remove the override and pass &init_config.language to template extraction methods instead.
  3. 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.

Comment thread codegenerator/cli/src/executor/init.rs Outdated
Ecosystem::Fuel {
init_flow: init_config::fuel::InitFlow::Template(template),
} => {
init_config.language = Language::TypeScript;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of mutating init_config I'd prefer passing Language::TypeScript directly as an argument instead of &init_config.language

@nikbhintade nikbhintade Nov 7, 2025

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is needed.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it. I was just using code from the previous file.

Comment thread codegenerator/cli/src/template_dirs.rs Outdated
lang
))?;

println!("language files at {:?}", lang_files.parent_path);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it for debugging or for user?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry about that, it was for my debugging and forgot to remove.

@DZakh DZakh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good 👍 I left a few comments/questions

@DZakh DZakh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for introduction to your PR, I've done some fixes by myself. Needed it merged to release 2.32.2 version 🙏

@DZakh DZakh enabled auto-merge (squash) November 7, 2025 12:14

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 rescript is silently ignored during template initialization (Fuel and EVM templates currently hardcode Language::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

📥 Commits

Reviewing files that changed from the base of the PR and between 75e08c3 and 8316ead.

📒 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

@DZakh DZakh merged commit 1fc77a8 into main Nov 7, 2025
7 checks passed
@DZakh DZakh deleted the nb/remove-lang-selection branch November 7, 2025 12:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants