Skip to content

Basic updates - #3

Merged
LunaStev merged 1 commit into
masterfrom
basic-updates
Aug 2, 2025
Merged

LunaStev merged 1 commit into
masterfrom
basic-updates

Conversation

@LunaStev

@LunaStev LunaStev commented Aug 2, 2025 •

Copy link
Copy Markdown
Member

Added setup command and deleted wavec dependency.

Summary by CodeRabbit

  • New Features

    • Added a command to install the "wavec" compiler, with optional version selection.
    • Introduced a terminal spinner animation to show progress during installation.
  • Improvements

    • Enhanced error handling and user feedback when running the "wavec" compiler; users are now prompted to install it if not found.
  • Chores

    • Removed dependency on the internal "wavec" crate, reducing external dependencies.

@coderabbitai

coderabbitai Bot commented Aug 2, 2025 •

Copy link
Copy Markdown

Walkthrough

This update removes the internal dependency on the "wavec" crate, replacing internal API calls with external command-line invocations of the "wavec" tool. It introduces a new setup wavec command for installing "wavec" via a shell script, adds a terminal spinner for installation feedback, and updates module declarations accordingly.

Changes

Cohort / File(s) Change Summary
Dependency Removal
Cargo.toml, src/version.rs
Removed the "wavec" crate dependency and related imports.
Module Declarations
src/commands/mod.rs
Added public module declaration for setup.
Run Command Refactor
src/commands/run.rs
Replaced internal wavec API call with an external process invocation and error handling.
Setup Command Addition
src/commands/setup.rs
Introduced install_wavec function to install "wavec" via shell script, with optional version argument.
Main Command Dispatch
src/main.rs
Added support for setup wavec command, parsing optional version flag, and invoking installer.
Spinner Utility
src/spinner.rs
Added a terminal spinner function to provide feedback during installation processes.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI as Vex CLI
    participant OS as System Shell

    User->>CLI: vex run <main_path>
    CLI->>OS: Execute "wavec run <main_path>"
    OS-->>CLI: Returns status
    CLI-->>User: Print error if wavec not found

    User->>CLI: vex setup wavec [--version <ver>]
    CLI->>OS: curl https://.../install.sh | bash -s -- [version]
    CLI->>CLI: show_spinner("Installing wavec...", child)
    OS-->>CLI: Returns status
    CLI-->>User: Print success or error message
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15 minutes

Possibly related PRs

  • LunaStev/Vex#1: Directly related, as it previously added the "wavec" crate dependency and internal usage, which this PR now removes and replaces with external command execution and a setup command.

Poem

A hop and a skip, dependencies trimmed,
Now "wavec" runs outside, not within.
With a spinner that twirls, and a setup so neat,
Installing your tools is now quite a treat!
🐇✨

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch basic-updates

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🧹 Nitpick comments (3)
src/spinner.rs (2)

3-6: Consider making spinner frames configurable.

The function signature is appropriate, but the hardcoded spinner frames could be made configurable for different use cases.

-pub fn show_spinner(message: &str, mut child: std::process::Child) -> std::process::ExitStatus {
-    let frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
+pub fn show_spinner(message: &str, mut child: std::process::Child) -> std::process::ExitStatus {
+    show_spinner_with_frames(message, child, &["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"])
+}
+
+pub fn show_spinner_with_frames(message: &str, mut child: std::process::Child, frames: &[&str]) -> std::process::ExitStatus {

20-24: Consider allowing graceful error handling instead of exit.

The error handling immediately exits the program, which may not be appropriate for all use cases. Consider returning a Result type instead.

-pub fn show_spinner(message: &str, mut child: std::process::Child) -> std::process::ExitStatus {
+pub fn show_spinner(message: &str, mut child: std::process::Child) -> Result<std::process::ExitStatus, Box<dyn std::error::Error>> {
     // ... existing code ...
             Err(e) => {
-                eprintln!("❌ Failed to wait on child process: {}", e);
-                std::process::exit(1);
+                return Err(Box::new(e));
             }
src/commands/setup.rs (1)

4-33: Consider cross-platform compatibility and installation verification.

The current implementation has platform-specific limitations and could benefit from additional robustness:

  1. Windows compatibility: This implementation won't work on Windows due to bash/curl dependencies
  2. Installation verification: Consider verifying the installation worked by checking if wavec is now available in PATH
  3. Configuration: Consider making the installer URL configurable

Consider these architectural improvements:

// Add after installation
fn verify_wavec_installation() -> bool {
    Command::new("wavec")
        .arg("--version")
        .output()
        .map(|output| output.status.success())
        .unwrap_or(false)
}

// Use in install_wavec after installation
if status.success() {
    if verify_wavec_installation() {
        println!("✅ wavec installed and verified successfully.");
    } else {
        eprintln!("⚠️ wavec installation completed but verification failed.");
    }
}

For Windows support, consider using PowerShell or providing Windows-specific installation instructions.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f8905d5 and ff1ef53.

📒 Files selected for processing (7)
  • Cargo.toml (1 hunks)
  • src/commands/mod.rs (1 hunks)
  • src/commands/run.rs (2 hunks)
  • src/commands/setup.rs (1 hunks)
  • src/main.rs (2 hunks)
  • src/spinner.rs (1 hunks)
  • src/version.rs (0 hunks)
💤 Files with no reviewable changes (1)
  • src/version.rs
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/commands/mod.rs (2)
src/commands/check.rs (1)
  • check (4-51)
src/commands/init.rs (1)
  • init (4-43)
🔇 Additional comments (8)
src/spinner.rs (2)

1-1: LGTM: Clean and appropriate imports.

The imports are well-chosen for the spinner functionality - thread/Duration for timing, io::Write for flushing output.


7-19: Solid spinner implementation with proper process handling.

The spinner loop correctly uses try_wait() to avoid blocking and provides smooth animation updates. The terminal clearing with spaces is a good practice.

src/commands/mod.rs (1)

5-5: LGTM: Consistent module declaration.

The addition of the setup module follows the existing pattern and is properly declared.

Cargo.toml (1)

6-8: LGTM: Dependency removal aligns with architectural change.

Removing the wavec crate dependency is consistent with the shift to using the external wavec CLI tool instead of the internal API.

src/main.rs (2)

5-5: LGTM: Appropriate import addition.

The import of install_wavec from the setup module is correctly added.


10-10: LGTM: Spinner module declaration.

The spinner module is properly declared.

src/commands/run.rs (1)

4-4: LGTM: Appropriate import for external command execution.

The addition of std::process::Command import is necessary for the new external CLI approach.

src/commands/setup.rs (1)

1-3: LGTM for imports and module structure.

The imports are appropriate for the functionality being implemented.

Comment thread src/commands/run.rs
Comment on lines +33 to +45
let status = Command::new("wavec")
.arg("run")
.arg(&main_path)
.status();

match status {
Ok(s) if s.success() => (),
Ok(_) => println!("wavec not found."),
Err(_) => {
println!("wavec not found.");
println!("Run `vex setup wavec` to install the compiler.");
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Improve error handling and user messaging.

The current implementation has a few issues:

  1. Line 40 treats a failed exit status as "wavec not found" which is misleading - it could be a compilation error
  2. The error handling could be more specific about different failure modes
                 let status = Command::new("wavec")
                     .arg("run")
                     .arg(&main_path)
                     .status();

                 match status {
                     Ok(s) if s.success() => (),
-                    Ok(_) => println!("wavec not found."),
+                    Ok(_) => println!("❌ wavec execution failed."),
                     Err(_) => {
-                        println!("wavec not found.");
+                        println!("❌ wavec not found.");
                         println!("Run `vex setup wavec` to install the compiler.");
                     }
                 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
let status = Command::new("wavec")
.arg("run")
.arg(&main_path)
.status();
match status {
Ok(s) if s.success() => (),
Ok(_) => println!("wavec not found."),
Err(_) => {
println!("wavec not found.");
println!("Run `vex setup wavec` to install the compiler.");
}
}
let status = Command::new("wavec")
.arg("run")
.arg(&main_path)
.status();
match status {
Ok(s) if s.success() => (),
Ok(_) => println!("❌ wavec execution failed."),
Err(_) => {
println!("❌ wavec not found.");
println!("Run `vex setup wavec` to install the compiler.");
}
}
🤖 Prompt for AI Agents
In src/commands/run.rs around lines 33 to 45, the error handling for the
Command::new("wavec") execution is misleading because a non-success exit status
is treated as "wavec not found," which could actually indicate a compilation
error. To fix this, differentiate between the command not being found (Err
variant) and the command running but returning a failure status (Ok with
!success). Update the messages accordingly to reflect whether the compiler is
missing or if there was a compilation error, providing clearer guidance to the
user.

Comment thread src/commands/setup.rs
Comment on lines +5 to +8
let version_arg = match version {
Some(ver) => format!("--version {}", ver),
None => "latest".to_string(),
};

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix inconsistent version argument formatting.

The version argument formatting is inconsistent - when a version is provided, it uses --version {ver} format, but when None, it just uses "latest". This inconsistency could cause the installer script to fail.

Consider making the formatting consistent:

-    let version_arg = match version {
-        Some(ver) => format!("--version {}", ver),
-        None => "latest".to_string(),
-    };
+    let version_arg = match version {
+        Some(ver) => format!("--version {}", ver),
+        None => "--version latest".to_string(),
+    };
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
let version_arg = match version {
Some(ver) => format!("--version {}", ver),
None => "latest".to_string(),
};
let version_arg = match version {
Some(ver) => format!("--version {}", ver),
None => "--version latest".to_string(),
};
🤖 Prompt for AI Agents
In src/commands/setup.rs around lines 5 to 8, the version argument formatting is
inconsistent: it uses "--version {ver}" when a version is provided but just
"latest" when None. To fix this, ensure both cases use the same argument format
by changing the None case to "--version latest" so the installer script receives
a consistent version argument.

Comment thread src/commands/setup.rs
Comment on lines +12 to +24
let full_command = format!(
"curl -fsSL https://wave-lang.dev/install.sh | bash -s -- {}",
version_arg
);

let child = Command::new("bash")
.arg("-c")
.arg(&full_command)
.stdin(Stdio::null())
.stdout(Stdio::null()) // 로그 출력 안 함
.stderr(Stdio::null())
.spawn()
.expect("❌ Failed to start wavec installer");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue

Critical security vulnerabilities and platform compatibility issues.

This implementation has several critical issues:

  1. Command injection vulnerability: The version_arg is directly interpolated into the shell command without sanitization
  2. No script integrity verification: Downloading and executing scripts from external URLs without checksum verification is a security risk
  3. Platform compatibility: Hardcoded bash usage won't work on Windows
  4. Missing dependency checks: No verification that curl and bash are available

Apply these fixes:

+use std::ffi::OsStr;
+
 pub fn install_wavec(version: Option<&str>) {
+    // Validate version parameter to prevent injection
+    if let Some(ver) = version {
+        if !ver.chars().all(|c| c.is_alphanumeric() || c == '.' || c == '-') {
+            eprintln!("❌ Invalid version format");
+            return;
+        }
+    }
+
     let version_arg = match version {
-        Some(ver) => format!("--version {}", ver),
-        None => "latest".to_string(),
+        Some(ver) => vec!["--version", ver],
+        None => vec!["--version", "latest"],
     };
 
-    println!("⬇️ Installing wavec ({})...", version_arg);
+    println!("⬇️ Installing wavec...");
 
-    let full_command = format!(
-        "curl -fsSL https://wave-lang.dev/install.sh | bash -s -- {}",
-        version_arg
-    );
-
-    let child = Command::new("bash")
-        .arg("-c")
-        .arg(&full_command)
+    let mut curl_cmd = Command::new("curl");
+    curl_cmd.args(&["-fsSL", "https://wave-lang.dev/install.sh"]);
+    
+    let mut bash_cmd = Command::new("bash");
+    bash_cmd.args(&["-s", "--"]).args(&version_arg);
+    
+    // Chain curl output to bash input (simplified example)
+    let child = bash_cmd
         .stdin(Stdio::null())
-        .stdout(Stdio::null()) // 로그 출력 안 함
-        .stderr(Stdio::null())
+        .stdout(Stdio::null())
+        .stderr(Stdio::piped()) // Keep stderr for error reporting
         .spawn()
-        .expect("❌ Failed to start wavec installer");
+        .expect("❌ Failed to start installer");

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In src/commands/setup.rs lines 12 to 24, fix the command injection by sanitizing
or validating version_arg before use; add checksum verification for the
downloaded script to ensure integrity; replace hardcoded "bash" with a
platform-appropriate method to support Windows and other OSes; and add checks to
verify that required dependencies like curl and bash are installed before
running the command.

Comment thread src/commands/setup.rs
Comment on lines +26 to +32
let status = show_spinner("Installing wavec...", child);

if status.success() {
println!("✅ wavec installed successfully.");
} else {
eprintln!("❌ wavec installation failed.");
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Improve error reporting for better user experience.

While the spinner and basic success/failure feedback are good, consider improving error reporting by capturing and displaying stderr output when installation fails.

     let status = show_spinner("Installing wavec...", child);
 
     if status.success() {
         println!("✅ wavec installed successfully.");
     } else {
-        eprintln!("❌ wavec installation failed.");
+        eprintln!("❌ wavec installation failed. Exit code: {:?}", status.code());
+        eprintln!("Check your internet connection and try again.");
     }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
let status = show_spinner("Installing wavec...", child);
if status.success() {
println!("✅ wavec installed successfully.");
} else {
eprintln!("❌ wavec installation failed.");
}
let status = show_spinner("Installing wavec...", child);
if status.success() {
println!("✅ wavec installed successfully.");
} else {
eprintln!("❌ wavec installation failed. Exit code: {:?}", status.code());
eprintln!("Check your internet connection and try again.");
}
🤖 Prompt for AI Agents
In src/commands/setup.rs around lines 26 to 32, the current code only prints a
generic failure message when the installation fails. To improve error reporting,
capture the stderr output from the installation process and display it in the
error message. Modify the code to retrieve the error output from the child
process and include it in the eprintln! call when status.success() is false.

Comment thread src/main.rs
Comment on lines +27 to +34
} else if args.len() > 3 && args[1] == "setup" && args[2] == "wavec" {
let version = if args.len() > 5 && args[3] == "--version" {
Some(args[4].as_str())
} else {
None
};

install_wavec(version);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix the argument parsing logic for setup command.

The current logic has several issues:

  1. Line 27 checks args.len() > 3 but should be >= 3 for basic "setup wavec" command
  2. Line 28 checks args.len() > 5 but should be >= 5 for version flag
  3. The version parsing doesn't handle the case where --version is provided without a value
-    } else if args.len() > 3 && args[1] == "setup" && args[2] == "wavec" {
-        let version = if args.len() > 5 && args[3] == "--version" {
-            Some(args[4].as_str())
+    } else if args.len() >= 3 && args[1] == "setup" && args[2] == "wavec" {
+        let version = if args.len() >= 5 && args[3] == "--version" {
+            Some(args[4].as_str())
         } else {
             None
         };
🤖 Prompt for AI Agents
In src/main.rs around lines 27 to 34, update the argument length checks to use
>= instead of > to correctly handle the minimum required arguments for the
"setup wavec" command and the version flag. Additionally, add logic to verify
that when the "--version" flag is present, a corresponding version value exists
to avoid out-of-bounds access or missing version handling. Adjust the
conditional checks and parsing accordingly to ensure robust argument validation.

@LunaStev
LunaStev merged commit 867727d into master Aug 2, 2025
@LunaStev
LunaStev deleted the basic-updates branch March 19, 2026 08:52
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.

1 participant