Skip to content

Commit

Permalink
Merge pull request #568 from DannyBen/update/global-variables-location
Browse files Browse the repository at this point in the history
Move root variables from `run()` to `initialize()`
  • Loading branch information
DannyBen authored Nov 1, 2024
2 parents 5d1d4a9 + 478ead4 commit 947418f
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion examples/render-mandoc/docs/download.1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.\" Automatically generated by Pandoc 3.2
.\"
.TH "download" "1" "October 2024" "Version 0.1.0" "Sample application"
.TH "download" "1" "November 2024" "Version 0.1.0" "Sample application"
.SH NAME
\f[B]download\f[R] \- Sample application
.SH SYNOPSIS
Expand Down
2 changes: 1 addition & 1 deletion examples/render-mandoc/docs/download.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
% download(1) Version 0.1.0 | Sample application
% Lana Lang
% October 2024
% November 2024

NAME
==================================================
Expand Down
2 changes: 1 addition & 1 deletion lib/bashly/views/command/function.gtx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
= view_marker

> {{ function_name }}_command() {
= render(:variables).indent(2) if variables&.any?
= render(:variables).indent(2)
= load_user_file(filename).indent 2
> }
>
1 change: 1 addition & 0 deletions lib/bashly/views/command/initialize.gtx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

if root_command?
>
= render(:variables).indent(2)
= render(:environment_variables_default).indent 2
end

Expand Down
1 change: 0 additions & 1 deletion lib/bashly/views/command/run.gtx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
if has_unique_args_or_flags?
> declare -A unique_lookup=()
end
= render(:variables).indent(2) if variables&.any?
> normalize_input "$@"
> parse_requirements "${input[@]}"
if user_file_exist?('before')
Expand Down
10 changes: 6 additions & 4 deletions lib/bashly/views/command/variables.gtx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
= view_marker
if variables.any?
= view_marker

variables.each do |var|
= var.render(:definition)
end
variables.each do |var|
= var.render(:definition)
end
end
2 changes: 1 addition & 1 deletion spec/approvals/examples/render-mandoc
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ ISSUE TRACKER
AUTHORS
Lana Lang.

Version 0.1.0 October 2024 download(1)
Version 0.1.0 November 2024 download(1)

0 comments on commit 947418f

Please sign in to comment.