File tree Expand file tree Collapse file tree 5 files changed +55
-19
lines changed
Expand file tree Collapse file tree 5 files changed +55
-19
lines changed Original file line number Diff line number Diff line change @@ -64,23 +64,41 @@ giv_config() {
6464 esac
6565 done < " $GIV_CONFIG_FILE "
6666 fi
67- # Convert GIV_... keys to user keys for output
68- while IFS= read -r line; do
69- case " $line " in
67+ # Convert GIV_... keys to user keys for output from config file
68+ if [ -s " $GIV_CONFIG_FILE " ]; then
69+ while IFS= read -r line; do
70+ case " $line " in
71+ GIV_* )
72+ k=${line# GIV_}
73+ k=${k%% =* }
74+ key=$( printf ' %s' " $k " | tr ' A-Z_' ' a-z.' )
75+ value=" ${line#* =} "
76+ printf ' %s\n' " $key =$value "
77+ ;;
78+ * =* )
79+ printf ' %s\n' " $line "
80+ ;;
81+ * )
82+ ;;
83+ esac
84+ done < " $GIV_CONFIG_FILE "
85+ fi
86+
87+ # Also show environment variables with GIV_ prefix that may have been loaded from --config-file
88+ for var in $( env | grep ' ^GIV_' ) ; do
89+ case " $var " in
7090 GIV_* )
71- k=${line # GIV_}
91+ k=${var # GIV_}
7292 k=${k%% =* }
7393 key=$( printf ' %s' " $k " | tr ' A-Z_' ' a-z.' )
74- value=" ${line #* =} "
75- printf ' %s\n ' " $key = $value "
76- ;;
77- * = * )
78- printf ' %s\n ' " $line "
94+ value=" ${var #* =} "
95+ # Only show if not already shown from config file
96+ if [ -z " $( grep " ^GIV_ $k = " " $GIV_CONFIG_FILE " 2> /dev/null ) " ] ; then
97+ printf ' %s\n ' " $key = $value "
98+ fi
7999 ;;
80- * )
81- ;;
82100 esac
83- done < " $GIV_CONFIG_FILE "
101+ done
84102 ;;
85103 --get|get)
86104 key=" $2 "
Original file line number Diff line number Diff line change 1010if [ -n " ${GIV_TEST_MOCKS:- } " ] && [ -f " ${GIV_TEST_MOCKS:- } " ]; then
1111 . " $GIV_TEST_MOCKS "
1212fi
13+
1314# Function to generate documents based on a prompt template
1415cmd_document () {
1516 # Use environment variables set by unified parser
Original file line number Diff line number Diff line change 77
88# Wrapper to call document.sh with appropriate arguments
99if [ -f " ${GIV_SRC_DIR} /commands/document.sh" ]; then
10+ # Set the template file directly via environment variable
11+ template_path=" ${GIV_TEMPLATE_DIR} /release_notes_prompt.md"
12+ export GIV_PROMPT_FILE=" ${template_path} "
1013 # Delegate to the subcommand script
11- " ${GIV_SRC_DIR} /commands/document.sh" " $@ " \
12- --template " ${GIV_TEMPLATE_DIR} /release_notes_prompt.md"
14+ " ${GIV_SRC_DIR} /commands/document.sh" " $@ "
1315 exit 0
1416else
1517 echo " Available subcommands: $( find " ${GIV_SRC_DIR} /commands" -maxdepth 1 -type f -name ' *.sh' -exec basename {} .sh \; | tr ' \n' ' ' ) " >&2
Original file line number Diff line number Diff line change @@ -139,9 +139,25 @@ if [ -f "${GIV_SRC_DIR}/commands/${GIV_SUBCMD}.sh" ]; then
139139 [ " ${GIV_DEBUG} " = " true" ] && printf ' Executing subcommand: %s\n' " ${GIV_SUBCMD} " >&2
140140 case " ${GIV_SUBCMD} " in
141141 config|init)
142- # These commands need access to raw positional arguments
143- shift # Remove subcommand name
144- " ${GIV_SRC_DIR} /commands/${GIV_SUBCMD} .sh" " $@ "
142+ # These commands need access to subcommand arguments only
143+ # Extract arguments after the subcommand name, skipping global options
144+ subcommand_args=" "
145+ found_subcommand=false
146+ for arg in " $@ " ; do
147+ if [ " $found_subcommand " = " true" ]; then
148+ subcommand_args=" $subcommand_args $arg "
149+ elif [ " $arg " = " $GIV_SUBCMD " ]; then
150+ found_subcommand=true
151+ fi
152+ done
153+ [ " ${GIV_DEBUG} " = " true" ] && printf ' Config subcommand args: %s\n' " $subcommand_args " >&2
154+ if [ -n " $subcommand_args " ]; then
155+ # Use eval to properly handle quoted arguments
156+ eval set -- " $subcommand_args "
157+ " ${GIV_SRC_DIR} /commands/${GIV_SUBCMD} .sh" " $@ "
158+ else
159+ " ${GIV_SRC_DIR} /commands/${GIV_SUBCMD} .sh"
160+ fi
145161 ;;
146162 * )
147163 # Other commands use environment variables from unified parser
Original file line number Diff line number Diff line change 55
66load ' test_helper/bats-support/load'
77load ' test_helper/bats-assert/load'
8+ load ' helpers/setup.sh'
89
9- export GIV_HOME=" $BATS_TEST_DIRNAME /.giv"
10- export TMPDIR=" $GIV_HOME /.tmp"
1110
1211setup () {
1312 # Create isolated test environment
You can’t perform that action at this time.
0 commit comments