major changes
- Added documentation via mdbook - Created basic VS code extension - Implemented if else blocks and changed some syntax - fixed some issues
This commit is contained in:
72
docs/src/getting-started/installation.md
Normal file
72
docs/src/getting-started/installation.md
Normal file
@@ -0,0 +1,72 @@
|
||||
# Installation
|
||||
|
||||
> ⚠️ This documentation is AI-generated and may contain errors.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
Rush is written in Rust, so you'll need:
|
||||
- Rust toolchain (rustc, cargo)
|
||||
- Git (to clone the repository)
|
||||
|
||||
## Installing Rust
|
||||
|
||||
If you don't have Rust installed, get it from [rustup.rs](https://rustup.rs/):
|
||||
|
||||
```bash
|
||||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
|
||||
```
|
||||
|
||||
## Building Rush
|
||||
|
||||
1. Clone the repository:
|
||||
```bash
|
||||
git clone https://github.com/yourusername/rush.git
|
||||
cd rush
|
||||
```
|
||||
|
||||
2. Build the project:
|
||||
```bash
|
||||
cargo build --release
|
||||
```
|
||||
|
||||
3. The binary will be available at `./target/release/rush`
|
||||
|
||||
## Optional: Install System-Wide
|
||||
|
||||
To make Rush available system-wide:
|
||||
|
||||
```bash
|
||||
cargo install --path .
|
||||
```
|
||||
|
||||
This installs Rush to `~/.cargo/bin/rush` (make sure `~/.cargo/bin` is in your PATH).
|
||||
|
||||
## Verifying Installation
|
||||
|
||||
Test your installation:
|
||||
|
||||
```bash
|
||||
./target/release/rush --version
|
||||
# or if installed system-wide:
|
||||
rush --version
|
||||
```
|
||||
|
||||
Create a test script `hello.rsh`:
|
||||
```rush
|
||||
#!/usr/bin/env rush
|
||||
|
||||
NAME = "World"
|
||||
echo "Hello, $NAME!"
|
||||
```
|
||||
|
||||
Make it executable and run it:
|
||||
```bash
|
||||
chmod +x hello.rsh
|
||||
./target/release/rush hello.rsh
|
||||
```
|
||||
|
||||
You should see: `Hello, World!`
|
||||
|
||||
## Next Steps
|
||||
|
||||
Now that Rush is installed, proceed to the [Quick Start](./quick-start.md) guide.
|
||||
172
docs/src/getting-started/quick-start.md
Normal file
172
docs/src/getting-started/quick-start.md
Normal file
@@ -0,0 +1,172 @@
|
||||
# Quick Start
|
||||
|
||||
> ⚠️ This documentation is AI-generated and may contain errors.
|
||||
|
||||
This guide will walk you through creating your first Rush script.
|
||||
|
||||
## Your First Script
|
||||
|
||||
Create a file called `hello.rsh`:
|
||||
|
||||
```rush
|
||||
#!/usr/bin/env rush
|
||||
|
||||
# Variables are assigned with =
|
||||
NAME = "Rush"
|
||||
echo "Hello from $NAME!"
|
||||
```
|
||||
|
||||
Run it:
|
||||
```bash
|
||||
rush hello.rsh
|
||||
```
|
||||
|
||||
Output:
|
||||
```
|
||||
Hello from Rush!
|
||||
```
|
||||
|
||||
## Variables and Interpolation
|
||||
|
||||
Variables are automatically interpolated in strings:
|
||||
|
||||
```rush
|
||||
PROJECT = "my-app"
|
||||
VERSION = "1.0.0"
|
||||
FULL_NAME = "$PROJECT-v$VERSION"
|
||||
|
||||
echo "Building $FULL_NAME"
|
||||
# Output: Building my-app-v1.0.0
|
||||
```
|
||||
|
||||
## Using Built-in Variables
|
||||
|
||||
Rush provides several built-in variables:
|
||||
|
||||
```rush
|
||||
echo "Current user: $USER"
|
||||
echo "Home directory: $HOME"
|
||||
|
||||
if $IS_ROOT {
|
||||
echo "Running as root"
|
||||
} else {
|
||||
echo "Running as normal user"
|
||||
}
|
||||
```
|
||||
|
||||
## Conditional Logic
|
||||
|
||||
Use `if`/`else` for branching:
|
||||
|
||||
```rush
|
||||
ENV = "production"
|
||||
|
||||
if $ENV {
|
||||
echo "Environment: $ENV"
|
||||
}
|
||||
|
||||
if not $IS_ROOT {
|
||||
echo "Warning: Not running as root"
|
||||
} else {
|
||||
echo "Running with elevated privileges"
|
||||
}
|
||||
```
|
||||
|
||||
## Loops
|
||||
|
||||
Iterate over items with `for`:
|
||||
|
||||
```rush
|
||||
# Loop over space-separated items
|
||||
for name in Alice Bob Charlie {
|
||||
echo "Hello, $name!"
|
||||
}
|
||||
|
||||
# Use variables in loops
|
||||
SERVERS = "web-1 web-2 web-3"
|
||||
for server in web-1 web-2 web-3 {
|
||||
echo "Deploying to $server"
|
||||
}
|
||||
```
|
||||
|
||||
## Parallel Execution
|
||||
|
||||
Run tasks concurrently:
|
||||
|
||||
```rush
|
||||
parallel {
|
||||
run {
|
||||
echo "Task 1: Starting..."
|
||||
echo "Task 1: Complete"
|
||||
}
|
||||
|
||||
run {
|
||||
echo "Task 2: Starting..."
|
||||
echo "Task 2: Complete"
|
||||
}
|
||||
|
||||
run {
|
||||
echo "Task 3: Starting..."
|
||||
echo "Task 3: Complete"
|
||||
}
|
||||
}
|
||||
|
||||
echo "All tasks finished"
|
||||
```
|
||||
|
||||
The output from parallel blocks may be interleaved since they run concurrently.
|
||||
|
||||
## A Complete Example
|
||||
|
||||
Here's a more complete script showing multiple features:
|
||||
|
||||
```rush
|
||||
#!/usr/bin/env rush
|
||||
|
||||
# Configuration
|
||||
PROJECT = "web-app"
|
||||
ENV = "staging"
|
||||
DEPLOY_DIR = "/var/www/$PROJECT"
|
||||
|
||||
echo "Deployment Script for $PROJECT"
|
||||
echo "Environment: $ENV"
|
||||
echo ""
|
||||
|
||||
# Pre-flight checks
|
||||
if not $IS_ROOT {
|
||||
echo "Warning: Not root. Some operations may fail."
|
||||
}
|
||||
|
||||
# Build steps
|
||||
echo "Running build steps:"
|
||||
for step in lint test build {
|
||||
echo " - $step"
|
||||
}
|
||||
|
||||
# Deploy to multiple servers in parallel
|
||||
echo ""
|
||||
echo "Deploying to $ENV servers..."
|
||||
|
||||
parallel {
|
||||
run {
|
||||
echo "[server-1] Deploying $PROJECT"
|
||||
echo "[server-1] Complete"
|
||||
}
|
||||
|
||||
run {
|
||||
echo "[server-2] Deploying $PROJECT"
|
||||
echo "[server-2] Complete"
|
||||
}
|
||||
}
|
||||
|
||||
echo ""
|
||||
echo "Deployment complete!"
|
||||
```
|
||||
|
||||
## Next Steps
|
||||
|
||||
Learn more about Rush's features:
|
||||
- [Variables](../language/variables.md) - Deep dive into variable handling
|
||||
- [Control Flow](../language/control-flow.md) - Conditionals and branching
|
||||
- [Loops](../language/loops.md) - Iteration patterns
|
||||
- [Parallel Execution](../language/parallel.md) - Concurrency in Rush
|
||||
Reference in New Issue
Block a user