Fix "in N minutes" parsing and VHS tape errors
- Strip "in " prefix before passing to date -d (was always broken) - Fix quickstart tape: -B3 → -B4 for resume grep (Job: is 4 lines back) - Fix notifications tape: -f ~/backup.sh → -c (file doesn't exist) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
8781ac9f2f
commit
32ac2c3d5f
4 changed files with 206 additions and 1 deletions
78
demo/editmode.tape
Normal file
78
demo/editmode.tape
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
# systab — Edit Mode with Notification Flags
|
||||
# Demonstrates the crontab-style editor with :flags syntax.
|
||||
|
||||
Output demo/editmode.gif
|
||||
Set Shell bash
|
||||
Set Width 1200
|
||||
Set Height 600
|
||||
Set FontSize 16
|
||||
|
||||
Set TypingSpeed 50ms
|
||||
|
||||
Sleep 1s
|
||||
|
||||
# First create some jobs to edit
|
||||
Type "# Create some jobs to work with"
|
||||
Enter
|
||||
Sleep 500ms
|
||||
Type "systab -t 'every 5 minutes' -c 'echo ping'"
|
||||
Enter
|
||||
Sleep 2s
|
||||
Type "systab -t daily -c '/home/user/backup.sh' -i"
|
||||
Enter
|
||||
Sleep 2s
|
||||
|
||||
# Open edit mode with EDITOR=nano for visibility
|
||||
Type "# Open edit mode — add notifications, create and modify jobs"
|
||||
Enter
|
||||
Sleep 1s
|
||||
Type "EDITOR=nano systab -E"
|
||||
Sleep 500ms
|
||||
Enter
|
||||
Sleep 3s
|
||||
|
||||
# In nano: navigate to the end of the file
|
||||
# Ctrl+V = page down in nano, then Down to reach last line
|
||||
Ctrl+V
|
||||
Sleep 500ms
|
||||
Down 5
|
||||
Sleep 500ms
|
||||
|
||||
# Add a new job line with notification flags
|
||||
Type "new:i,e=admin@example.com | hourly | curl -s https://example.com/health"
|
||||
Sleep 1s
|
||||
Enter
|
||||
|
||||
Sleep 1s
|
||||
|
||||
# Save and exit nano
|
||||
Ctrl+O
|
||||
Sleep 500ms
|
||||
Enter
|
||||
Sleep 500ms
|
||||
Ctrl+X
|
||||
Sleep 3s
|
||||
|
||||
# Show the result
|
||||
Type "# See the changes applied"
|
||||
Enter
|
||||
Sleep 500ms
|
||||
Type "systab -S"
|
||||
Sleep 500ms
|
||||
Enter
|
||||
Sleep 4s
|
||||
|
||||
# Re-open edit mode to show flags are persisted
|
||||
Type "# Re-open edit mode — flags are persisted"
|
||||
Enter
|
||||
Sleep 1s
|
||||
Type "EDITOR=nano systab -E"
|
||||
Sleep 500ms
|
||||
Enter
|
||||
Sleep 3s
|
||||
|
||||
# Just view and exit without changes
|
||||
Ctrl+X
|
||||
Sleep 2s
|
||||
|
||||
Sleep 2s
|
||||
62
demo/notifications.tape
Normal file
62
demo/notifications.tape
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
# systab — Notifications
|
||||
# Shows status-aware desktop and email notifications.
|
||||
|
||||
Output demo/notifications.gif
|
||||
Set Shell bash
|
||||
Set Width 1200
|
||||
Set Height 600
|
||||
Set FontSize 16
|
||||
|
||||
Set TypingSpeed 50ms
|
||||
|
||||
Sleep 1s
|
||||
|
||||
# Desktop notification — success case
|
||||
Type "# Desktop notification on success/failure"
|
||||
Enter
|
||||
Sleep 1s
|
||||
Type "systab -t 'in 1 minute' -c 'echo success' -i"
|
||||
Sleep 500ms
|
||||
Enter
|
||||
Sleep 2s
|
||||
|
||||
# Desktop notification — failure case
|
||||
Type "systab -t 'in 1 minute' -c 'exit 1' -i"
|
||||
Sleep 500ms
|
||||
Enter
|
||||
Sleep 2s
|
||||
|
||||
# Email notification
|
||||
Type "# Email notification via sendmail"
|
||||
Enter
|
||||
Sleep 1s
|
||||
Type "systab -t 'in 1 minute' -c 'echo test' -m user@example.com"
|
||||
Sleep 500ms
|
||||
Enter
|
||||
Sleep 2s
|
||||
|
||||
# Both notifications
|
||||
Type "# Both desktop and email"
|
||||
Enter
|
||||
Sleep 1s
|
||||
Type "systab -t 'every day at 9am' -c '/home/user/backup.sh' -i -m admin@example.com"
|
||||
Sleep 500ms
|
||||
Enter
|
||||
Sleep 2s
|
||||
|
||||
# Show the generated service file to see ExecStopPost lines
|
||||
Type "# Inspect generated service file"
|
||||
Enter
|
||||
Sleep 1s
|
||||
Type "cat ~/.config/systemd/user/systab_*.service | head -20"
|
||||
Sleep 500ms
|
||||
Enter
|
||||
Sleep 4s
|
||||
|
||||
# Check status
|
||||
Type "systab -S"
|
||||
Sleep 500ms
|
||||
Enter
|
||||
Sleep 3s
|
||||
|
||||
Sleep 2s
|
||||
62
demo/quickstart.tape
Normal file
62
demo/quickstart.tape
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
# systab — Quick Start
|
||||
# Creates a few jobs, checks status, views logs, then cleans up.
|
||||
|
||||
Output demo/quickstart.gif
|
||||
Set Shell bash
|
||||
Set Width 1200
|
||||
Set Height 600
|
||||
Set FontSize 16
|
||||
|
||||
Set TypingSpeed 50ms
|
||||
|
||||
Sleep 1s
|
||||
|
||||
# Create a recurring job
|
||||
Type "systab -t 'every 5 minutes' -c 'echo health check OK'"
|
||||
Sleep 500ms
|
||||
Enter
|
||||
Sleep 2s
|
||||
|
||||
# Create a one-time job
|
||||
Type "systab -t 'in 30 minutes' -c 'echo reminder: meeting soon'"
|
||||
Sleep 500ms
|
||||
Enter
|
||||
Sleep 2s
|
||||
|
||||
# Check status of all jobs
|
||||
Type "systab -S"
|
||||
Sleep 500ms
|
||||
Enter
|
||||
Sleep 4s
|
||||
|
||||
# View logs
|
||||
Type "systab -L"
|
||||
Sleep 500ms
|
||||
Enter
|
||||
Sleep 3s
|
||||
|
||||
# Pause a job (uses the first job ID from status)
|
||||
Type "systab -P $(systab -S 2>/dev/null | grep -m1 'Job:' | awk '{print $2}')"
|
||||
Sleep 500ms
|
||||
Enter
|
||||
Sleep 2s
|
||||
|
||||
# Show it's paused
|
||||
Type "systab -S"
|
||||
Sleep 500ms
|
||||
Enter
|
||||
Sleep 3s
|
||||
|
||||
# Resume it
|
||||
Type "systab -R $(systab -S 2>/dev/null | grep -m1 'Disabled' -B4 | grep 'Job:' | awk '{print $2}')"
|
||||
Sleep 500ms
|
||||
Enter
|
||||
Sleep 2s
|
||||
|
||||
# Clean up completed one-time jobs
|
||||
Type "systab -C"
|
||||
Sleep 500ms
|
||||
Enter
|
||||
Sleep 2s
|
||||
|
||||
Sleep 2s
|
||||
5
systab
5
systab
|
|
@ -158,8 +158,11 @@ parse_time() {
|
|||
fi
|
||||
|
||||
# Try to parse with date command (one-time specs)
|
||||
# Strip "in " prefix for natural phrasing ("in 5 minutes" → "5 minutes")
|
||||
local date_spec="$time_spec"
|
||||
[[ "${date_spec,,}" == in\ * ]] && date_spec="${date_spec:3}"
|
||||
local parsed_date
|
||||
if parsed_date=$(date -d "$time_spec" '+%Y-%m-%d %H:%M:%S' 2>/dev/null); then
|
||||
if parsed_date=$(date -d "$date_spec" '+%Y-%m-%d %H:%M:%S' 2>/dev/null); then
|
||||
echo "$parsed_date"
|
||||
return
|
||||
fi
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue