DSL Syntax
Complete reference for Ninja's Domain-Specific Language (DSL).
Overview
The Ninja DSL is a shell-like command language for service management and automation.
Command Structure
<command> [arguments] [options]Core Commands
Shuriken Management
list
List installed shurikens.
# Basic list
list
# With state information
list stateOutput:
example-service (Running)
webserver (Idle)select
Select a shuriken for subsequent operations.
select <name>
# Example
select webserverexit
Deselect the current shuriken.
exitstart
Start the selected shuriken.
select myapp
startstop
Stop the selected shuriken.
select myapp
stopinstall
Install a shuriken package.
install <path>
# Example
install ./service.shuriken
install ~/Downloads/com.example.app.shurikenConfiguration
configure
Generate configuration from template.
# Basic configuration
configure
# With inline options
configure {
port = 8080
host = "localhost"
debug = true
}
# Multi-line block
configure {
option1 = value1;
option2 = value2;
option3 = value3
}set
Set a configuration option.
set <key> <value>
# Examples
set port 8080
set host "localhost"
set debug trueget
Get a configuration option value.
get <key>
# Example
get porttoggle
Toggle a boolean option.
toggle <key>
# Example
toggle debugScript Execution
execute
Execute a Ninja script file.
execute <path>
# Examples
execute ./setup.ns
execute scripts/deploy.luaHTTP Server
http
Start the HTTP API server.
http <port>
# Example
http 8080Help
help
Display help information.
helpValue Types
The DSL automatically detects value types:
Strings
# With quotes (preserves spaces)
set message "Hello World"
set path 'C:\Program Files\App'
# Without quotes (single word)
set name valueNumbers
# Integers
set port 8080
set timeout 30
# Floats
set ratio 0.75
set delay 2.5Booleans
set enabled true
set debug falseComments
Both comment styles are supported:
# Hash-style comment
// Slash-style comment
configure {
port = 8080 # Inline comment
debug = true // Also inline
}Configuration Blocks
Use blocks for multiple options:
configure {
# Server settings
port = 8080
host = "0.0.0.0"
workers = 4
# Features
debug = true
ssl = false
}Semicolon separator (optional):
configure {
port = 8080;
host = "localhost";
debug = true
}Command Chaining
Execute multiple commands:
select webserver
configure { port = 9000 }
start
list stateDeep Links
GUI supports shurikenctl:// URLs:
shurikenctl://start?shuriken=myapp
shurikenctl://stop?shuriken=myapp
shurikenctl://configure?shuriken=myapp&port=8080Interactive Mode (REPL)
Start interactive mode:
shurikenctlPrompt:
ninja> list
example-service (Running)
ninja> select example-service
Selected: example-service
ninja> stop
Service stopped
ninja> exitScript Files
Create DSL script files (.dsl extension recommended):
deploy.dsl:
# Install application
install ./myapp.shuriken
# Configure
select myapp
configure {
port = 8080
host = "0.0.0.0"
workers = 4
}
# Start service
start
# Verify
list stateExecute:
shurikenctl run deploy.dslError Handling
DSL commands return success/error status:
# Success
select myapp
start
# → "Service started successfully"
# Error: no such shuriken
select nonexistent
# → "No such shuriken: nonexistent"
# Error: already running
select myapp
start
# → Error: Service already runningVariables (Not Supported)
The DSL does not support variables or loops. For complex logic, use Lua scripts:
setup.ns:
-- Lua script with full Ninja API
local services = {"web1", "web2", "web3"}
for _, service in ipairs(services) do
log.info("Starting " .. service)
-- Use Ninja API here
endBest Practices
- Use select for multiple operations - Avoid repeating shuriken names
- Group configuration - Use blocks for related options
- Add comments - Document complex scripts
- Error check - Verify command success before proceeding
- Keep it simple - Use Lua for complex logic
Examples
Quick Start
install ./myapp.shuriken
select myapp
configure
startConfiguration Update
select webserver
set port 9000
set workers 8
configure
stop
startMulti-Service Management
select web1
start
select web2
start
select database
start
list stateDevelopment Workflow
# Configure and test existing shuriken
select myapp
configure { port = 3000 }
start
# Make changes
stop
# (edit files)
start
# List status
list stateIntegration
With CLI
# Direct command sequence
shurikenctl run -c "select myapp"
shurikenctl run -c "start"
# Script file
shurikenctl run script.dslWith GUI
The GUI executes DSL commands internally:
- Start button →
select <name>thenstart - Configure dialog →
configure { ... } - Install button →
install <path>
With HTTP API
curl -X POST http://localhost:8080/api/dsl/execute \
-H "Content-Type: application/json" \
-d '{"command": "select myapp\nstart"}'See also: CLI Reference, Lua API Reference, Developer DSL Guide