setup-plan.sh 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #!/usr/bin/env bash
  2. set -e
  3. # Parse command line arguments
  4. JSON_MODE=false
  5. ARGS=()
  6. for arg in "$@"; do
  7. case "$arg" in
  8. --json)
  9. JSON_MODE=true
  10. ;;
  11. --help|-h)
  12. echo "Usage: $0 [--json]"
  13. echo " --json Output results in JSON format"
  14. echo " --help Show this help message"
  15. exit 0
  16. ;;
  17. *)
  18. ARGS+=("$arg")
  19. ;;
  20. esac
  21. done
  22. # Get script directory and load common functions
  23. SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
  24. source "$SCRIPT_DIR/common.sh"
  25. # Get all paths and variables from common functions
  26. eval $(get_feature_paths)
  27. # Check if we're on a proper feature branch (only for git repos)
  28. check_feature_branch "$CURRENT_BRANCH" "$HAS_GIT" || exit 1
  29. # Ensure the feature directory exists
  30. mkdir -p "$FEATURE_DIR"
  31. # Copy plan template if it exists
  32. TEMPLATE="$REPO_ROOT/.specify/templates/plan-template.md"
  33. if [[ -f "$TEMPLATE" ]]; then
  34. cp "$TEMPLATE" "$IMPL_PLAN"
  35. echo "Copied plan template to $IMPL_PLAN"
  36. else
  37. echo "Warning: Plan template not found at $TEMPLATE"
  38. # Create a basic plan file if template doesn't exist
  39. touch "$IMPL_PLAN"
  40. fi
  41. # Output results
  42. if $JSON_MODE; then
  43. printf '{"FEATURE_SPEC":"%s","IMPL_PLAN":"%s","SPECS_DIR":"%s","BRANCH":"%s","HAS_GIT":"%s"}\n' \
  44. "$FEATURE_SPEC" "$IMPL_PLAN" "$FEATURE_DIR" "$CURRENT_BRANCH" "$HAS_GIT"
  45. else
  46. echo "FEATURE_SPEC: $FEATURE_SPEC"
  47. echo "IMPL_PLAN: $IMPL_PLAN"
  48. echo "SPECS_DIR: $FEATURE_DIR"
  49. echo "BRANCH: $CURRENT_BRANCH"
  50. echo "HAS_GIT: $HAS_GIT"
  51. fi