CLI for Oops - Safe text file editing with automatic backup
npm install @iyulab/oops-clibash
Global installation (recommended)
npm install -g @iyulab/oops-cli
Local installation
npm install @iyulab/oops-cli
`
Quick Start
`bash
Start tracking a file (creates backup automatically)
oops config.txt
Edit the file with your preferred editor
nano config.txt
Check what changed
oops diff config.txt
Apply changes permanently
oops keep config.txt
Or undo changes back to backup
oops undo config.txt
Check status of all tracked files
oops status
`
Commands
$3
#### oops
Start tracking a file safely. Creates a backup and initializes workspace if needed.
`bash
oops myfile.txt
oops src/config.js
oops /path/to/important.conf
`
#### oops diff [file]
Show changes in tracked files.
`bash
oops diff # Show all changes
oops diff config.txt # Show changes in specific file
`
#### oops keep
Apply changes and stop tracking the file.
`bash
oops keep config.txt
`
#### oops undo
Revert file to backup and stop tracking.
`bash
oops undo config.txt
`
#### oops status
Show status of all tracked files and workspace information.
`bash
oops status
`
Options
$3
- -V, --version - Show version number
- -v, --verbose - Enable verbose output
- -q, --quiet - Suppress output
- --no-color - Disable colored output
- --workspace - Use specific workspace path
- --yes - Skip confirmation prompts
- -h, --help - Display help
$3
#### diff
- --tool - Use external diff tool (code, vimdiff, meld)
- --no-color - Disable colored diff output
#### keep
- --no-confirm - Skip confirmation prompt
#### undo
- --no-confirm - Skip confirmation prompt
Environment Variables
- OOPS_WORKSPACE - Workspace path (default: temp directory)
- OOPS_DIFF_TOOL - External diff tool (code, vimdiff, meld)
- NO_COLOR - Disable colored output
Examples
$3
`bash
Start tracking
oops nginx.conf
â ⨠Creating temporary workspace at: /tmp/oops-abc123
â đ Starting to track: nginx.conf
â đž Backup created: .oops/files/def456/backup
Make changes
vim nginx.conf
Review changes
oops diff nginx.conf
â Shows colored diff output
Apply changes
oops keep nginx.conf
â â
Changes applied to nginx.conf
`
$3
`bash
Track multiple files
oops config.js
oops package.json
oops README.md
Check status
oops status
â Workspace: /tmp/oops-abc123 (3 files tracked)
â đ config.js - modified
â đ package.json - modified
â đ README.md - clean
Review all changes
oops diff
â Shows changes for all modified files
`
$3
`bash
Use VS Code for diff
oops diff --tool code config.txt
Set environment variable
export OOPS_DIFF_TOOL=vimdiff
oops diff config.txt
`
$3
`bash
Use custom workspace
oops --workspace ./my-workspace config.txt
Set via environment
export OOPS_WORKSPACE=/path/to/workspace
oops config.txt
`
Safety Features
- Automatic Backup: Every tracked file gets a backup before changes
- Workspace Isolation: Each project operates independently
- Confirmation Prompts: Safety prompts for destructive operations
- Health Checks: Automatic detection of workspace corruption
- Atomic Operations: All-or-nothing changes to prevent partial failures
Integration
$3
The CLI works well with any text editor:
`bash
With vim
oops config.txt && vim config.txt && oops diff config.txt
With VS Code
oops package.json && code package.json
With nano
oops .bashrc && nano .bashrc && oops keep .bashrc
`
$3
`bash
#!/bin/bash
Safe config editing script
FILE="$1"
oops "$FILE"
$EDITOR "$FILE"
echo "Review changes:"
oops diff "$FILE"
read -p "Apply changes? (y/n) " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
oops keep "$FILE"
echo "â
Changes applied"
else
oops undo "$FILE"
echo "âŠī¸ Changes reverted"
fi
`
Troubleshooting
$3
File not found error
`bash
oops: error: File does not exist: nonexistent.txt
`
Make sure the file path is correct and the file exists.
Permission denied
`bash
oops: error: Permission denied: /etc/passwd
`
Ensure you have read/write permissions for the file.
Workspace corruption
`bash
oops: error: Workspace corrupted, please run: oops clean
`
The workspace has integrity issues. Clean and reinitialize.
$3
`bash
oops help # General help
oops help status # Command-specific help
oops --help # Options and examples
``