Skip to content

Commit d2d7ba0

Browse files
committed
refactor command.start template
1 parent fdadcfc commit d2d7ba0

File tree

10 files changed

+26
-31
lines changed

10 files changed

+26
-31
lines changed

examples/hooks/src/before.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
## before hook
22
##
3-
## Any code here will be placed inside a `before_hook()` function and called
4-
## before running any command (but after processing its arguments).
3+
## Any code here will be placed inside the `before_hook()` function and called
4+
## before running any command (but after argument processing is complete).
55
##
6-
## - The processed args are available to you here as `$args` and `$extra_args`
7-
## - The raw input array is also available in read-only mode as `$input`
6+
## - The processed args are available to you here as `args` and `extra_args`
7+
## - The raw input array is also available in read-only mode as `input`
88
##
99
## You can safely delete this file if you do not need it.
1010
echo "==[ Before Hook Called ]=="
11-
inspect_args
11+
inspect_args

examples/hooks/src/initialize.sh

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@
33
## Any code here will be placed inside the `initialize()` function and called
44
## before running anything else.
55
##
6-
## - The raw command line arguments are available to you here as "$@"
7-
## - If you wish to override the raw arguments before they are processed,
8-
## simply define an array named `input_override`:
9-
##
10-
## declare -g -a input_override=("modified" "args")
6+
## The original command line arguments are available in the `command_line` array.
7+
## You can modify this array to adjust or override the input before the app runs,
8+
## though this is usually only needed for advanced use cases.
119
##
1210
## You can safely delete this file if you do not need it.

examples/render-mandoc/docs/download.1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.\" Automatically generated by Pandoc 3.2
22
.\"
3-
.TH "download" "1" "January 2026" "Version 0.1.0" "Sample application"
3+
.TH "download" "1" "August 2025" "Version 0.1.0" "Sample application"
44
.SH NAME
55
\f[B]download\f[R] \- Sample application
66
.SH SYNOPSIS

examples/render-mandoc/docs/download.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
% download(1) Version 0.1.0 | Sample application
22
% Lana Lang
3-
% January 2026
3+
% August 2025
44

55
NAME
66
==================================================
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
## before hook
22
##
3-
## Any code here will be placed inside a `before_hook()` function and called
4-
## before running any command (but after processing its arguments).
3+
## Any code here will be placed inside the `before_hook()` function and called
4+
## before running any command (but after argument processing is complete).
55
##
6-
## - The processed args are available to you here as `$args` and `$extra_args`
7-
## - The raw input array is also available in read-only mode as `$input`
6+
## - The processed args are available to you here as `args` and `extra_args`
7+
## - The raw input array is also available in read-only mode as `input`
88
##
99
## You can safely delete this file if you do not need it.
1010
echo "==[ Before Hook Called ]=="
11-
inspect_args
11+
inspect_args

lib/bashly/libraries/hooks/initialize.sh

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@
33
## Any code here will be placed inside the `initialize()` function and called
44
## before running anything else.
55
##
6-
## - The raw command line arguments are available to you here as "$@"
7-
## - If you wish to override the raw arguments before they are processed,
8-
## simply define an array named `input_override`:
9-
##
10-
## declare -g -a input_override=("modified" "args")
6+
## The original command line arguments are available in the `command_line` array.
7+
## You can modify this array to adjust or override the input before the app runs,
8+
## though this is usually only needed for advanced use cases.
119
##
1210
## You can safely delete this file if you do not need it.

lib/bashly/views/command/start.gtx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
= view_marker
22

3-
> {{ Settings.function_name :initialize }} "$@"
4-
> if [[ -v input_override ]]; then
5-
> {{ Settings.function_name :run }} "${input_override[@]}"
6-
> else
7-
> {{ Settings.function_name :run }} "$@"
8-
> fi
3+
> command_line=("$@")
4+
> {{ Settings.function_name :initialize }}
5+
> {{ Settings.function_name :run }} "${command_line[@]}"

spec/approvals/cli/preview/no-args

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/usr/bin/env bash
22
...
3-
run "$@"
3+
fi

spec/bashly/commands/preview_spec.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717

1818
it 'prints the generated cli script' do
1919
expect { subject.execute %w[preview] }.to output_approval('cli/preview/no-args')
20-
.except(/env bash\n.*\n\s*run "\$@"\n.*/m, "env bash\n...\nrun \"$@\"")
20+
.except(/env bash\n.*\n\s*fi\n/m, "env bash\n...\nfi\b")
2121
end
2222
end
2323
end
24+
25+

spec/bashly/script/wrapper_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
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 "$@"'
14+
expect(lines[-2]).to eq ' run "${command_line[@]}"'
1515
end
1616
end
1717

0 commit comments

Comments
 (0)