183 lines
5.4 KiB
Bash
Executable File
183 lines
5.4 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Task Manager - Main CLI Orchestrator
|
|
# Compose smaller scripts to create a unified task management system
|
|
|
|
set -o pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
LIB_DIR="$SCRIPT_DIR/lib"
|
|
|
|
source "$LIB_DIR/task-common.sh"
|
|
|
|
# Check if jq is available
|
|
check_jq() {
|
|
if ! command -v jq &> /dev/null; then
|
|
log_warn "jq not found - some features will have limited functionality"
|
|
fi
|
|
}
|
|
|
|
# Print help
|
|
show_help() {
|
|
cat <<'EOF'
|
|
|
|
Task Manager - Unified Task Tracking System
|
|
|
|
USAGE:
|
|
task.sh <command> [options]
|
|
|
|
COMMANDS:
|
|
|
|
parse <file|dir> Extract tasks from Markdown files as JSON
|
|
Options:
|
|
--json Output as JSON (default)
|
|
--table Output as formatted table
|
|
|
|
query <criteria> Query and filter tasks from JSON input (via pipe)
|
|
Options:
|
|
--status <status> Filter by status (Draft|Planning|In Progress|Completed|Blocked)
|
|
--priority <priority> Filter by priority (critical|high|medium|low)
|
|
--owner <owner> Filter by owner
|
|
--id <id> Find specific task by ID
|
|
--search <text> Search in title/description
|
|
--unassigned Find unassigned tasks
|
|
--blockers Find tasks with dependencies
|
|
--dependents <id> Find tasks that depend on this task
|
|
--count <field> Count tasks by field
|
|
--sort <field> Sort by field
|
|
--table Format as table
|
|
|
|
update <file> <id> [options] Update task properties in place
|
|
Options:
|
|
--status <status> Set status
|
|
--priority <priority> Set priority
|
|
--owner <owner> Set owner
|
|
--effort <effort> Set effort estimate
|
|
|
|
report [type] Generate reports from task JSON (via pipe)
|
|
Types:
|
|
--summary Summary statistics
|
|
--board Kanban board view
|
|
--priority Tasks grouped by priority
|
|
--owner Tasks grouped by owner
|
|
--dependencies Dependency graph
|
|
--burndown Progress/burndown chart
|
|
--csv Export as CSV
|
|
--all All reports
|
|
|
|
validate [type] Validate task consistency (via pipe)
|
|
Types:
|
|
--schema Validate schema compliance
|
|
--dependencies Validate dependencies exist
|
|
--uniqueness Check for duplicate IDs
|
|
--all Full validation (default)
|
|
|
|
list Quick task listing with filtering
|
|
Options:
|
|
(same as query)
|
|
|
|
EXAMPLES:
|
|
|
|
# Parse all tasks from a plan file
|
|
./task.sh parse pln-001-roadmap.md
|
|
|
|
# Parse all tasks in a directory
|
|
./task.sh parse ./specs/
|
|
|
|
# Find all high-priority tasks
|
|
./task.sh parse . | ./task.sh query --priority high
|
|
|
|
# Find tasks assigned to Alice
|
|
./task.sh parse . | ./task.sh query --owner "Alice" --table
|
|
|
|
# Find unassigned tasks across all plans
|
|
./task.sh parse specs/ | ./task.sh query --unassigned --table
|
|
|
|
# Generate a kanban board
|
|
./task.sh parse . | ./task.sh report --board
|
|
|
|
# Export tasks as CSV
|
|
./task.sh parse . | ./task.sh report --csv
|
|
|
|
# Validate all tasks
|
|
./task.sh parse . | ./task.sh validate --all
|
|
|
|
# Update task status
|
|
./task.sh update pln-001-roadmap.md tsk-001 --status "In Progress"
|
|
|
|
# Update multiple fields
|
|
./task.sh update pln-001-roadmap.md tsk-001 --status "Completed" --priority "high"
|
|
|
|
PIPING EXAMPLES:
|
|
|
|
# Find completed tasks by priority
|
|
./task.sh parse . | ./task.sh query --status "Completed" | ./task.sh query --priority "high" | ./task.sh report --summary
|
|
|
|
# Find all blockers assigned to a person
|
|
./task.sh parse . | ./task.sh query --owner "Bob" | ./task.sh query --blockers | ./task.sh report --board
|
|
|
|
# Generate CSV of all in-progress tasks
|
|
./task.sh parse . | ./task.sh query --status "In Progress" | ./task.sh report --csv > tasks.csv
|
|
|
|
NOTES:
|
|
- JSON piping allows composing commands together
|
|
- Update operations modify files in place with automatic backups
|
|
- All text output uses colors (disable with NO_COLOR env var)
|
|
- Requires jq for full functionality (graceful degradation without it)
|
|
|
|
EOF
|
|
}
|
|
|
|
# Main command routing
|
|
main() {
|
|
check_jq
|
|
|
|
if [[ $# -eq 0 ]] || [[ "$1" == "-h" ]] || [[ "$1" == "--help" ]]; then
|
|
show_help
|
|
return 0
|
|
fi
|
|
|
|
local command="$1"
|
|
shift
|
|
|
|
case "$command" in
|
|
parse)
|
|
bash "$LIB_DIR/task-parse.sh" "$@"
|
|
;;
|
|
query)
|
|
bash "$LIB_DIR/task-query.sh" "$@"
|
|
;;
|
|
update)
|
|
bash "$LIB_DIR/task-update.sh" "$@"
|
|
;;
|
|
report)
|
|
bash "$LIB_DIR/task-report.sh" "$@"
|
|
;;
|
|
validate)
|
|
bash "$LIB_DIR/task-validate.sh" "$@"
|
|
;;
|
|
list)
|
|
# Convenience command: parse + query
|
|
if [[ $# -eq 0 ]]; then
|
|
log_error "Usage: task.sh list <file|dir> [query options]"
|
|
return 1
|
|
fi
|
|
local target="$1"
|
|
shift
|
|
bash "$LIB_DIR/task-parse.sh" "$target" | bash "$LIB_DIR/task-query.sh" "$@"
|
|
;;
|
|
--version)
|
|
echo "Task Manager v0.1.0"
|
|
;;
|
|
*)
|
|
log_error "Unknown command: $command"
|
|
echo ""
|
|
show_help
|
|
return 1
|
|
;;
|
|
esac
|
|
}
|
|
|
|
# Execute main
|
|
main "$@"
|