|
7 | 7 | # This file is sourced by wireflow.sh and lib/task.sh. |
8 | 8 | # ============================================================================= |
9 | 9 |
|
| 10 | +# ============================================================================= |
| 11 | +# Shared Option Parsing |
| 12 | +# ============================================================================= |
| 13 | + |
| 14 | +# Parse common execution options shared between run and task modes |
| 15 | +# Arguments: |
| 16 | +# $1 - option: The option flag being parsed |
| 17 | +# $2+ - remaining arguments |
| 18 | +# Returns: |
| 19 | +# Sets PARSE_CONSUMED to number of args consumed (0 = unknown option) |
| 20 | +# Sets global config variables (MODEL, TEMPERATURE, etc.) |
| 21 | +# Usage: |
| 22 | +# parse_common_option "$1" "${@:2}" |
| 23 | +# if [[ $PARSE_CONSUMED -gt 0 ]]; then |
| 24 | +# shift $PARSE_CONSUMED |
| 25 | +# fi |
| 26 | +PARSE_CONSUMED=0 |
| 27 | + |
| 28 | +parse_common_option() { |
| 29 | + local opt="$1" |
| 30 | + shift |
| 31 | + PARSE_CONSUMED=0 |
| 32 | + |
| 33 | + case "$opt" in |
| 34 | + --profile) |
| 35 | + [[ $# -eq 0 ]] && { echo "Error: --profile requires argument" >&2; return 1; } |
| 36 | + PROFILE="$1" |
| 37 | + CONFIG_SOURCE_MAP[PROFILE]="cli" |
| 38 | + PARSE_CONSUMED=2 |
| 39 | + ;; |
| 40 | + --model|-m) |
| 41 | + [[ $# -eq 0 ]] && { echo "Error: --model requires argument" >&2; return 1; } |
| 42 | + MODEL="$1" |
| 43 | + CONFIG_SOURCE_MAP[MODEL]="cli" |
| 44 | + PARSE_CONSUMED=2 |
| 45 | + ;; |
| 46 | + --enable-thinking) |
| 47 | + ENABLE_THINKING=true |
| 48 | + CONFIG_SOURCE_MAP[ENABLE_THINKING]="cli" |
| 49 | + PARSE_CONSUMED=1 |
| 50 | + ;; |
| 51 | + --disable-thinking) |
| 52 | + ENABLE_THINKING=false |
| 53 | + CONFIG_SOURCE_MAP[ENABLE_THINKING]="cli" |
| 54 | + PARSE_CONSUMED=1 |
| 55 | + ;; |
| 56 | + --thinking-budget) |
| 57 | + [[ $# -eq 0 ]] && { echo "Error: --thinking-budget requires argument" >&2; return 1; } |
| 58 | + THINKING_BUDGET="$1" |
| 59 | + CONFIG_SOURCE_MAP[THINKING_BUDGET]="cli" |
| 60 | + PARSE_CONSUMED=2 |
| 61 | + ;; |
| 62 | + --effort) |
| 63 | + [[ $# -eq 0 ]] && { echo "Error: --effort requires argument" >&2; return 1; } |
| 64 | + EFFORT="$1" |
| 65 | + CONFIG_SOURCE_MAP[EFFORT]="cli" |
| 66 | + PARSE_CONSUMED=2 |
| 67 | + ;; |
| 68 | + --temperature|-t) |
| 69 | + [[ $# -eq 0 ]] && { echo "Error: --temperature requires argument" >&2; return 1; } |
| 70 | + TEMPERATURE="$1" |
| 71 | + CONFIG_SOURCE_MAP[TEMPERATURE]="cli" |
| 72 | + PARSE_CONSUMED=2 |
| 73 | + ;; |
| 74 | + --max-tokens) |
| 75 | + [[ $# -eq 0 ]] && { echo "Error: --max-tokens requires argument" >&2; return 1; } |
| 76 | + MAX_TOKENS="$1" |
| 77 | + CONFIG_SOURCE_MAP[MAX_TOKENS]="cli" |
| 78 | + PARSE_CONSUMED=2 |
| 79 | + ;; |
| 80 | + --system|-p) |
| 81 | + [[ $# -eq 0 ]] && { echo "Error: --system requires argument" >&2; return 1; } |
| 82 | + IFS=',' read -ra SYSTEM_PROMPTS <<< "$1" |
| 83 | + CONFIG_SOURCE_MAP[SYSTEM_PROMPTS]="cli" |
| 84 | + PARSE_CONSUMED=2 |
| 85 | + ;; |
| 86 | + --format|-f) |
| 87 | + [[ $# -eq 0 ]] && { echo "Error: --format requires argument" >&2; return 1; } |
| 88 | + OUTPUT_FORMAT="$1" |
| 89 | + CONFIG_SOURCE_MAP[OUTPUT_FORMAT]="cli" |
| 90 | + PARSE_CONSUMED=2 |
| 91 | + ;; |
| 92 | + --enable-citations) |
| 93 | + ENABLE_CITATIONS=true |
| 94 | + CONFIG_SOURCE_MAP[ENABLE_CITATIONS]="cli" |
| 95 | + PARSE_CONSUMED=1 |
| 96 | + ;; |
| 97 | + --disable-citations) |
| 98 | + ENABLE_CITATIONS=false |
| 99 | + CONFIG_SOURCE_MAP[ENABLE_CITATIONS]="cli" |
| 100 | + PARSE_CONSUMED=1 |
| 101 | + ;; |
| 102 | + *) |
| 103 | + # Unknown option - caller handles |
| 104 | + PARSE_CONSUMED=0 |
| 105 | + ;; |
| 106 | + esac |
| 107 | + return 0 |
| 108 | +} |
| 109 | + |
10 | 110 | # ============================================================================= |
11 | 111 | # System Prompt Building |
12 | 112 | # ============================================================================= |
|
0 commit comments