| Crates.io | openscript_cli |
| lib.rs | openscript_cli |
| version | 0.1.0 |
| created_at | 2025-06-08 23:04:28.320171+00 |
| updated_at | 2025-06-08 23:04:28.320171+00 |
| description | Command-line interface for OpenScript |
| homepage | |
| repository | https://github.com/openscript-lang/openscript-rs |
| max_upload_size | |
| id | 1705320 |
| size | 95,260 |
A Modern AI-Powered Scripting Language for Automation and Development
OpenScript is a modern scripting language that seamlessly integrates artificial intelligence capabilities with traditional automation tools. Built in Rust for performance and safety, OpenScript combines the simplicity of shell scripting with the power of AI-driven development.
cargo install openscript_cli
git clone https://github.com/openscript-lang/openscript-rs.git
cd openscript-rs
cargo build --release
Create a file hello.os:
#!/usr/bin/env openscript
echo "Hello, OpenScript!"
# Variables and operations
let name = "Developer"
let greeting = "Welcome to OpenScript, " + name + "!"
echo greeting
# Functions
fn fibonacci(n) {
if n <= 1 {
return n
} else {
return fibonacci(n - 1) + fibonacci(n - 2)
}
}
echo "Fibonacci(10): " + fibonacci(10)
# HTTP requests
let response = http_get("https://api.github.com/users/octocat")
if response.status == 200 {
let user = json_parse(response.body)
echo "GitHub user: " + user.name
}
# AI integration (requires OPENAI_API_KEY)
if env_get("OPENAI_API_KEY") != null {
let ai_response = ai_complete("Explain the benefits of automation in software development")
echo "AI says: " + ai_response
}
Run the script:
openscript run hello.os
# Numbers
let age = 25
let pi = 3.14159
# Strings
let name = "OpenScript"
let multiline = """
This is a
multiline string
"""
# Booleans
let is_awesome = true
let is_ready = false
# Arrays
let numbers = [1, 2, 3, 4, 5]
let mixed = ["hello", 42, true, null]
# Objects
let user = {
"name": "Alice",
"age": 30,
"skills": ["Rust", "JavaScript", "Python"]
}
# Conditionals
if age >= 18 {
echo "Adult"
} else if age >= 13 {
echo "Teenager"
} else {
echo "Child"
}
# Loops
for i in 1..10 {
echo "Number: " + i
}
for item in ["apple", "banana", "cherry"] {
echo "Fruit: " + item
}
# While loops
let count = 0
while count < 5 {
echo "Count: " + count
count = count + 1
}
# Basic function
fn greet(name) {
return "Hello, " + name + "!"
}
# Function with multiple parameters
fn calculate_area(width, height) {
return width * height
}
# Higher-order functions
fn apply_operation(x, y, operation) {
return operation(x, y)
}
let add = fn(a, b) { return a + b }
let result = apply_operation(5, 3, add) # Returns 8
# Set your OpenAI API key
# export OPENAI_API_KEY="your-api-key-here"
# Simple completion
let response = ai_complete("Write a function to sort an array")
echo response
# Code generation
let code = ai_complete("Generate a Python function that reads a CSV file and returns a list of dictionaries")
write_file("generated_code.py", code)
# Text analysis
let text = "OpenScript is an innovative scripting language with AI capabilities."
let analysis = ai_complete("Analyze the sentiment and key themes in this text: " + text)
echo analysis
# GET request
let response = http_get("https://api.github.com/users/octocat")
if response.status == 200 {
let data = json_parse(response.body)
echo "User: " + data.name
echo "Repos: " + data.public_repos
}
# POST request
let post_data = {
"title": "Hello World",
"body": "This is a test post",
"userId": 1
}
let post_response = http_post(
"https://jsonplaceholder.typicode.com/posts",
json_stringify(post_data),
{"Content-Type": "application/json"}
)
echo "Post created with ID: " + json_parse(post_response.body).id
# Write to file
let data = {"name": "OpenScript", "version": "1.0.0"}
write_file("config.json", json_stringify(data))
# Read from file
let content = read_file("config.json")
let config = json_parse(content)
echo "App: " + config.name
# Directory operations
mkdir("temp")
let files = list_dir(".")
for file in files {
echo "File: " + file + " (" + file_size(file) + " bytes)"
}
length(str) - Get string lengthupper(str) - Convert to uppercaselower(str) - Convert to lowercasetrim(str) - Remove whitespacesplit(str, delimiter) - Split string into arrayjoin(array, delimiter) - Join array into stringreplace(str, old, new) - Replace textpush(array, item) - Add item to arraypop(array) - Remove last itemsort(array) - Sort arrayreverse(array) - Reverse arrayfilter(array, predicate) - Filter arraymap(array, function) - Transform arrayround(number) - Round to nearest integerfloor(number) - Round downceil(number) - Round upabs(number) - Absolute valuemin(a, b) - Minimum valuemax(a, b) - Maximum valuerandom() - Random number 0-1timestamp() - Current timestampsleep(seconds) - Pause executionenv_get(name) - Get environment variableexec(command) - Execute system commandopenscript repl
openscript run script.os
openscript run script.os --verbose
openscript eval "echo 'Hello World'"
openscript eval "2 + 3 * 4"
openscript check script.os
openscript install package-name
openscript list
openscript update
OpenScript is built with a modular architecture designed for extensibility and performance:
┌─────────────────────────────────────────────────────────────┐
│ OpenScript CLI │
├─────────────────────────────────────────────────────────────┤
│ OpenScript SDK │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────────────┐ │
│ │ AI Plugin │ │ HTTP Plugin │ │ FileSystem Plugin │ │
│ └─────────────┘ └─────────────┘ └─────────────────────┘ │
├─────────────────────────────────────────────────────────────┤
│ OpenScript Runtime │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────────────┐ │
│ │ Parser │ │ Interpreter │ │ Type System │ │
│ └─────────────┘ └─────────────┘ └─────────────────────┘ │
└─────────────────────────────────────────────────────────────┘
OpenScript is designed for performance while maintaining ease of use:
Script Execution: ~50,000 ops/sec
HTTP Requests: ~1,000 req/sec
File Operations: ~10,000 ops/sec
AI API Calls: Limited by OpenAI rate limits
git clone https://github.com/openscript-lang/openscript-rs.git
cd openscript-rs
cargo build --release
cargo test
cargo test --package openscript_sdk
cargo test --package openscript_cli
We welcome contributions! Please see our Contributing Guide for details.
openscript/ - Core language implementationopenscript_sdk/ - Standard library and AI integrationopenscript_cli/ - Command-line interfaceexamples/ - Example scripts and use casestests/ - Test suitesdocs/ - Documentation# Deploy application with AI-powered rollback decisions
let deployment_status = deploy_app("production")
if deployment_status.errors > 0 {
let ai_decision = ai_complete("Should we rollback this deployment? Errors: " + deployment_status.errors)
if contains(lower(ai_decision), "yes") {
rollback_deployment()
}
}
# Process CSV data with AI insights
let data = parse_csv("sales_data.csv")
let summary = analyze_sales_data(data)
let insights = ai_complete("Provide business insights for this sales data: " + json_stringify(summary))
write_file("sales_insights.md", insights)
# Automated API testing with intelligent assertions
let endpoints = ["/users", "/posts", "/comments"]
for endpoint in endpoints {
let response = http_get("https://api.example.com" + endpoint)
let validation = ai_complete("Is this API response valid? " + response.body)
assert(contains(lower(validation), "valid"))
}
# Monitor system health with AI-powered alerts
let metrics = get_system_metrics()
let health_check = ai_complete("Analyze these system metrics and provide health status: " + json_stringify(metrics))
if contains(lower(health_check), "critical") {
send_alert("System health critical: " + health_check)
}
OpenScript is released under the MIT License. See LICENSE for details.
Built with ❤️ in Rust for the future of automation