File tree Expand file tree Collapse file tree
fixtures/completions/core/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -200,5 +200,6 @@ var_aliases:
200200
201201# Choose different names for some of the internal functions.
202202function_names :
203+ start : ~
203204 run : ~
204205 initialize : ~
Original file line number Diff line number Diff line change 1313= render :initialize
1414= render :run
1515
16- >
16+ >
17+ = render :start
18+ >
1719if Settings.enabled? :sourcing
1820 > if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
19- = render( :start).indent 2
21+ > {{ Settings.function_name :start }} "$@"
2022 > fi
2123else
22- = render :start
24+ > {{ Settings.function_name :start }} "$@"
2325end
24- >
26+ >
Original file line number Diff line number Diff line change 11= view_marker
22
3- > command_line_args=("$@")
3+ > {{ Settings.function_name :start }}() {
44if Settings.completions?
5- > if [[ "${command_line_args[0]:-}" == "__complete" ]]; then
6- > completion_run "${command_line_args[@]:1}"
7- > else
5+ > if [[ ${1:-} == "__complete" ]]; then
6+ > completion_run "${@:2}"
7+ > return
8+ > fi
9+ end
10+ >
11+ > command_line_args=("$@")
812> {{ Settings.function_name :initialize }}
913> {{ Settings.function_name :run }} "${command_line_args[@]}"
10- > fi
11- else
12- > {{ Settings.function_name :initialize }}
13- > {{ Settings.function_name :run }} "${command_line_args[@]}"
14- end
14+ > }
Original file line number Diff line number Diff line change 423423 "description" : " Choose different names for some of the internal functions.\n https://bashly.dev/usage/settings/#function_names" ,
424424 "type" : " object" ,
425425 "properties" : {
426+ "start" : {
427+ "title" : " start" ,
428+ "description" : " Name for the start() function\n https://bashly.dev/usage/settings/#function_names" ,
429+ "oneOf" : [
430+ {
431+ "type" : " string" ,
432+ "minLength" : 1
433+ },
434+ {
435+ "type" : " null"
436+ }
437+ ]
438+ },
426439 "run" : {
427440 "title" : " run" ,
428441 "description" : " Name for the run() function\n https://bashly.dev/usage/settings/#function_names" ,
Original file line number Diff line number Diff line change @@ -52,4 +52,5 @@ Examples:
5252Stack trace:
5353 from ./download:<line> in `root_command`
5454 from ./download:<line> in `run`
55+ from ./download:<line> in `start`
5556 from ./download:<line> in `main`
Original file line number Diff line number Diff line change 1111 lines = subject . code . split "\n "
1212 expect ( lines [ 0 ..13 ] . join ( "\n " ) ) . to match_approval ( 'script/wrapper/code' )
1313 . except ( /\d +\. \d +\. \d +(\. rc\d )?/ )
14- expect ( lines [ - 3 ] ) . to eq ' run "${command_line_args[@]} "'
14+ expect ( lines ) . to include ' start "$@ "'
1515 end
1616 end
1717
4242 expect ( lines [ 2 ] ) . to eq '# :command.root_command'
4343 end
4444 end
45+
46+ context 'with a custom start function name' do
47+ around do |example |
48+ original_function_names = Settings . function_names
49+ Settings . function_names = { 'start' => 'custom_start' }
50+ example . run
51+ ensure
52+ Settings . function_names = original_function_names
53+ end
54+
55+ it 'uses the configured name for the definition and invocation' do
56+ expect ( subject . code ) . to include "custom_start() {\n "
57+ expect ( subject . code ) . to include "\n custom_start \" $@\" \n "
58+ end
59+ end
4560 end
4661end
Original file line number Diff line number Diff line change 1+ printf " initialize unexpectedly called\n"
2+ return 1
Original file line number Diff line number Diff line change @@ -348,6 +348,12 @@ properties:
348348 https://bashly.dev/usage/settings/#function_names
349349 type : object
350350 properties :
351+ start :
352+ title : start
353+ description : |-
354+ Name for the start() function
355+ https://bashly.dev/usage/settings/#function_names
356+ oneOf : *optional_string
351357 run :
352358 title : run
353359 description : |-
You can’t perform that action at this time.
0 commit comments