-
-
Notifications
You must be signed in to change notification settings - Fork 0
API Reference
Complete reference for all DotRun commands, options, and usage patterns. This page serves as the definitive command documentation.
dr [OPTIONS] [COMMAND] [ARGUMENTS...]Display help information.
dr --help # General help
dr script-name --help # Script-specific help (if script supports it)Display DotRun version information.
dr --version
# Output: DotRun v3.1.0List available scripts (short format).
dr -l # List all scripts
dr -l folder # List scripts in specific folderList available scripts with descriptions.
dr -L # List all scripts with descriptions
dr -L folder # List scripts in folder with descriptionsExecute a script. This is the default action when no command is specified.
Syntax:
dr <script-name>
dr <folder>/<script-name>
dr -s <script-name>Examples:
# Run personal script
dr hello
dr git/branch-cleanup
# Run with arguments
dr utils/backup ~/Documents /backup/location
# Run with environment variables
ENV_VAR=value dr script-nameCreate or edit a script. Creates a new script if it doesn't exist, or opens an existing one for editing.
Syntax:
dr set <script-name>
dr set <folder>/<script-name>
dr -s set <script-name>Examples:
dr set hello # Creates/edits hello.sh
dr set git/branch-tool # Creates/edits git/branch-tool.sh
dr set deploy/staging # Creates/edits deploy/staging.shWhat it does:
- Creates executable script file in appropriate directory (if new)
- Generates documentation template (if new)
- Opens script in your
$EDITOR
Move or rename a script with all documentation.
Aliases: rename
Syntax:
dr move <source-script> <destination-script>
dr rename <source-script> <destination-script>
dr -s move <source-script> <destination-script>Examples:
# Simple rename
dr move oldname newname
# Move to folder
dr move script git/script
# Rename and move
dr move old-script utils/new-script
# Reorganize folders
dr move git/old-tool docker/new-toolWhat it does:
- Moves script file to new location
- Updates documentation path
- Preserves file permissions
- Creates directories as needed
Remove a script and its documentation.
Aliases: remove
Syntax:
dr rm <script-name>
dr remove <script-name>
dr -s rm <script-name>Examples:
dr rm old-script
dr rm git/unused-toolSafety:
- Prompts for confirmation
- Removes both script and documentation
- Cannot be undone (unless using git)
Display inline script documentation (from ### DOC sections).
Syntax:
dr help <script-name>
dr -s help <script-name>Examples:
dr help git/branch-cleanup
# Shows usage, options, and examples from script commentsList available scripts in tree view.
Syntax:
dr -l [folder]
dr -s -l [folder]Examples:
dr -l # List all scripts
dr -l git # List scripts in git folderOutput:
git/
├── branch-cleanup
└── commit-helper
docker/
└── cleanup
List available scripts with descriptions in tree view.
Syntax:
dr -L [folder]
dr -s -L [folder]Examples:
dr -L # List all scripts with descriptions
dr -L git # List git folder scripts with descriptionsOutput:
git/
├── branch-cleanup - Clean up merged git branches
└── commit-helper - Interactive commit assistant
docker/
└── cleanup - Remove unused Docker containers
Aliases provide a way to store and manage shell aliases in DotRun. The default action is ADD/EDIT when no command is specified.
Create or edit an alias file.
Syntax:
dr -a <filename>
dr -a <folder>/<filename>
dr --aliases <filename>Examples:
dr -a git # Create/edit git aliases
dr -a docker/shortcuts # Create/edit docker/shortcuts aliasesList available alias files.
Syntax:
dr -a listOutput:
git
docker/shortcuts
utils/helpers
Move or rename an alias file.
Syntax:
dr -a move <source> <destination>Examples:
dr -a move old-aliases new-aliases
dr -a move aliases git/aliasesRemove an alias file.
Syntax:
dr -a rm <filename>Examples:
dr -a rm old-aliases
dr -a rm docker/unusedDisplay help for an alias file.
Syntax:
dr -a help <filename>Examples:
dr -a help gitInitialize the aliases folder structure.
Syntax:
dr -a initWhat it does:
- Creates the aliases directory structure
- Sets up necessary configuration files
Configs allow you to manage configuration files in DotRun. The default action is ADD/EDIT when no command is specified.
Create or edit a config file.
Syntax:
dr -c <filename>
dr -c <folder>/<filename>
dr --config <filename>Examples:
dr -c api # Create/edit api config
dr -c docker/settings # Create/edit docker/settings configList available config files.
Syntax:
dr -c listOutput:
api
docker/settings
database/connection
Move or rename a config file.
Syntax:
dr -c move <source> <destination>Examples:
dr -c move old-config new-config
dr -c move config docker/configRemove a config file.
Syntax:
dr -c rm <filename>Examples:
dr -c rm old-config
dr -c rm docker/unusedDisplay help for a config file.
Syntax:
dr -c help <filename>Examples:
dr -c help apiInitialize the configs folder structure.
Syntax:
dr -c initWhat it does:
- Creates the configs directory structure
- Sets up necessary configuration files
Collections are Git repositories containing reusable scripts that can be imported and managed.
Install a collection from a Git repository.
Syntax:
dr -col add <repository-url>Examples:
# Install from GitHub
dr -col add https://github.com/team/scripts.git
# Install from SSH
dr -col add git@github.com:team/scripts.gitWhat it does:
- Clones repository to collections directory
- Makes scripts available with
collection-name/script-namesyntax - Maintains separate git history
List all installed collections.
Syntax:
dr -col listOutput:
Collection Name Repository Last Updated
team-tools git@github.com:team/scripts.git 2026-01-15
personal-extras https://github.com/user/extras.git 2026-01-10
Check for updates to collections.
Syntax:
dr -col syncWhat it does:
- Checks all collections for available updates
- Displays which collections have updates available
- Does not automatically update (use
updatecommand)
Update a collection from its remote repository.
Syntax:
dr -col update <collection-name>
dr -col update allExamples:
# Update specific collection
dr -col update team-tools
# Update all collections
dr -col update allRemove an installed collection.
Syntax:
dr -col remove <collection-name>
dr -col rm <collection-name>Examples:
dr -col remove old-collection
dr -col rm team-toolsSafety:
- Prompts for confirmation
- Completely removes collection directory
Path to DotRun configuration directory.
Default: ~/.config/dotrun
Usage:
export DR_CONFIG="/custom/path"Preferred text editor for script editing.
Default: vi or system default
Usage:
export EDITOR="code" # VS Code
export EDITOR="vim" # Vim
export EDITOR="nano" # NanoEnable debug output.
Usage:
export DR_DEBUG=1
dr script-name # Shows debug outputGlobal configuration file (optional).
Location: ~/.config/dotrun/.drun-config
Format:
# Default editor
EDITOR=code
# Custom settings
DEFAULT_TEMPLATE=advanced
AUTO_LINT=trueCollection metadata file.
Location: collection-root/dotrun.collection.yml
Format:
name: "collection-name"
description: "Collection description"
author: "Author Name"
version: "1.0.0"
dependencies:
- git
- docker
- kubectl
optional_dependencies:
- glow
- jq
categories:
- deployment
- git
- dockerDotRun uses standard Unix exit codes:
| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | General error |
| 2 | Misuse of shell command |
| 126 | Script not executable |
| 127 | Script not found |
| 128+ | Fatal error signal |
#!/usr/bin/env bash
### DOC
# Script description
# Usage: dr script-name [options]
### DOC
set -euo pipefail
main() {
# Script logic here
echo "Script executed successfully"
}
main "$@"-
Shebang Line:
#!/usr/bin/env bash -
DOC Sections: Inline documentation between
### DOCmarkers -
Error Handling:
set -euo pipefailrecommended -
Main Function: Entry point function called with
"$@"
- Argument Parsing: Handle command-line options
-
Help Function: Built-in help with
--helpflag - Dependencies: Check for required tools
- Configuration: Load settings from environment or files
usage() {
cat <<EOF
Usage: dr script-name [OPTIONS] [ARGUMENTS]
OPTIONS:
-h, --help Show this help
-v, --verbose Enable verbose output
--option VALUE Specify option value
EXAMPLES:
dr script-name
dr script-name --verbose
dr script-name --option value
EOF
}
parse_args() {
while [[ $# -gt 0 ]]; do
case $1 in
-h | --help)
usage
exit 0
;;
-v | --verbose)
VERBOSE=true
shift
;;
--option)
OPTION_VALUE="$2"
shift 2
;;
*)
echo "Unknown option: $1"
usage
exit 1
;;
esac
done
}# Strict error handling
set -euo pipefail
# Custom error function
error() {
echo "❌ Error: $1" >&2
exit 1
}
# Usage
command || error "Command failed"
[[ -f "$file" ]] || error "File not found: $file"# Using DotRun helpers
source "$DR_CONFIG/helpers/pkg.sh"
validatePkg git docker kubectl
# Manual checking
check_dependencies() {
local deps=("git" "docker" "kubectl")
for dep in "${deps[@]}"; do
if ! command -v "$dep" >/dev/null 2>&1; then
error "Required dependency not found: $dep"
fi
done
}# Access git helpers
source "$DR_CONFIG/helpers/git.sh"
# Common patterns
cd_repo_root # Change to git root
current_branch=$(git_current_branch)
default_branch=$(git_default_branch)# Container management
docker_running() {
docker ps --format "table {{.Names}}\t{{.Status}}" | grep -v NAMES
}
docker_cleanup() {
docker container prune -f
docker image prune -f
}# Load configuration
load_config() {
local config_file="$HOME/.config/dotrun/.drun-config"
[[ -f "$config_file" ]] && source "$config_file"
}
# Environment-specific settings
case "${ENVIRONMENT:-development}" in
production)
API_URL="https://api.prod.com"
;;
staging)
API_URL="https://api.staging.com"
;;
*)
API_URL="https://api.dev.com"
;;
esac# Run with debug output
bash -x ~/.local/bin/dr script-name
# Check script syntax
bash -n ~/.config/dotrun/bin/script-name.sh
# Verbose DotRun execution
DR_DEBUG=1 dr script-name# Check DotRun installation
which dr
dr --version
# Check directory structure
ls -la ~/.config/dotrun/
# Test basic functionality
dr -l# List collection details
dr -col list
# Check collection structure
ls -la ~/.config/dotrun/collections/collection-name/
# Verify collection scripts
find ~/.config/dotrun/collections -name "*.sh" -exec bash -n {} \;| Command | Description |
|---|---|
dr <name> |
Run script |
dr set <name> |
Create/edit script |
dr -l [folder] |
List scripts (short) |
dr -L [folder] |
List scripts with descriptions |
dr help <name> |
Show script help |
dr move <old> <new> |
Move/rename script |
dr rm <name> |
Remove script |
| Command | Description |
|---|---|
dr -a <name> |
Create/edit alias file |
dr -a list |
List alias files |
dr -a move <old> <new> |
Move/rename alias file |
dr -a rm <name> |
Remove alias file |
dr -a help <name> |
Show alias help |
dr -a init |
Initialize aliases |
| Command | Description |
|---|---|
dr -c <name> |
Create/edit config file |
dr -c list |
List config files |
dr -c move <old> <new> |
Move/rename config file |
dr -c rm <name> |
Remove config file |
dr -c help <name> |
Show config help |
dr -c init |
Initialize configs |
| Command | Description |
|---|---|
dr -col add <url> |
Install collection |
dr -col list |
List collections |
dr -col sync |
Check for updates |
dr -col update <name> |
Update collection |
dr -col remove <name> |
Remove collection |
For more examples and use cases, see the Quick Start Tutorial and Workflow Recipes.