CLI Usage

The Rui command-line interface (CLI) allows you to run Rui programs and access various tools. This guide covers all the available commands and options.

Basic Usage

The basic syntax for running Rui programs is:

rui <filename>

Command Line Options

Version Information

Check the current version of Rui:

rui --version\nrui -v

File Extensions

Rui programs should use the .rui file extension:

# Good 
 rui program.rui 
 rui hello.rui 
 rui calculator.rui

# Also works (but not recommended) 
 rui program 
 rui hello

Error Handling

When Rui encounters an error, it will display helpful error messages:

rui nonexistent.rui\n# Error: File 'nonexistent.rui' not found\n\nrui syntax_error.rui\n# Error: Syntax error on line 3: unexpected token

Example: Hello World

Create a file called hello.rui:

write("Hello, World!")

Run it:

rui hello.rui

Output:

Hello, World!

Example: Interactive Program

Create a file called interactive.rui:

suppose name = "Alice"
suppose age = 25

write("Name: " + name)
write("Age: " + age)
write("Next year: " + (age + 1))

Run it:

rui interactive.rui

Output:

Name: Alice
Age: 25
Next year: 26

Example: Calculator

Create a file called calculator.rui:

define add(a, b) {
    return a + b
}

define multiply(a, b) {
    return a * b
}

suppose result1 = add(5, 3)
suppose result2 = multiply(4, 7)

write("5 + 3 = " + result1)
write("4 * 7 = " + result2)

Run it:

rui calculator.rui

Output:

5 + 3 = 8
4 * 7 = 28

Getting Help

If you encounter issues:

  1. Check the Installation guide
  2. Update Rui to latest version npm install -g rui-lang
  3. Verify your Rui syntax
  4. Use rui --help for command options
  5. Check the VS Code Integration for development tools

Next Steps

Now that you understand the CLI, learn about VS Code Integration to enhance your development experience.