Skip to content

Commit

Permalink
Merge pull request #583 from DannyBen/update/dependency-filter
Browse files Browse the repository at this point in the history
Update dependency check to show all missing dependencies at once
  • Loading branch information
DannyBen authored Dec 25, 2024
2 parents 5fbb406 + 4925106 commit a815867
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 10 deletions.
4 changes: 2 additions & 2 deletions examples/command-private/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Usage:
cli --version | -v

Commands:
connect Connect to the metaverse
connect Connect to the metaverse



Expand All @@ -84,7 +84,7 @@ Usage:
cli --version | -v

Commands:
connect Connect to the metaverse
connect Connect to the metaverse

Options:
--help, -h
Expand Down
2 changes: 1 addition & 1 deletion examples/dependencies-alt/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ args: none
deps:
- ${deps[git]} = /usr/bin/git
- ${deps[http_client]} = /usr/bin/curl
- ${deps[ruby]} = /home/vagrant/.rbenv/versions/3.3.0/bin/ruby
- ${deps[ruby]} = /home/vagrant/.rbenv/versions/3.3.6/bin/ruby


````
Expand Down
11 changes: 9 additions & 2 deletions examples/dependencies/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ commands:
dependencies:
- git
- curl
- shmurl
- dos
- netscape

- name: upload
help: Upload something
Expand All @@ -40,6 +41,7 @@ commands:
# The message can use colors from the colors library (bashly add colors).
dependencies:
mini-docker: install with $(green gem install mini-docker)
multi-docker: install with $(blue gem install multi-docker)
docker: visit https://docker.com for more information
````

Expand All @@ -50,7 +52,8 @@ commands:
### `$ ./cli download`

````shell
missing dependency: shmurl
missing dependency: dos
missing dependency: netscape


````
Expand All @@ -61,6 +64,10 @@ missing dependency: shmurl
missing dependency: mini-docker
install with gem install mini-docker

missing dependency: multi-docker
install with gem install multi-docker



````

Expand Down
4 changes: 3 additions & 1 deletion examples/dependencies/src/bashly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ commands:
dependencies:
- git
- curl
- shmurl
- dos
- netscape

- name: upload
help: Upload something
Expand All @@ -21,4 +22,5 @@ commands:
# The message can use colors from the colors library (bashly add colors).
dependencies:
mini-docker: install with $(green gem install mini-docker)
multi-docker: install with $(blue gem install multi-docker)
docker: visit https://docker.com for more information
2 changes: 1 addition & 1 deletion examples/render-mandoc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ ISSUE TRACKER
AUTHORS
Lana Lang.

Version 0.1.0 August 2024 download(1)
Version 0.1.0 December 2024 download(1)


````
Expand Down
5 changes: 5 additions & 0 deletions lib/bashly/views/command/dependencies_filter.gtx
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
if dependencies.any?
= view_marker

> missing_deps=
dependencies.each do |dependency|
= dependency.render :filter
end

> if [[ -n $missing_deps ]]; then
> exit 1
> fi
end
4 changes: 2 additions & 2 deletions lib/bashly/views/dependency/filter.gtx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
> if ! command -v {{ commands.join(' ') }} >/dev/null 2>&1; then
> printf "{{ strings[:missing_dependency] % { dependency: name } }}\n" >&2
if help
> printf "%s\n" "{{ help.sanitize_for_print }}" >&2
> printf "%s\n\n" "{{ help.sanitize_for_print }}" >&2
end
> exit 1
> missing_deps=1
if Settings.enabled? :deps_array
> else
> deps['{{ label }}']="$(command -v {{ commands.join(' ') }} | head -n1)"
Expand Down
7 changes: 6 additions & 1 deletion spec/approvals/examples/dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ created src/upload_command.sh
created ./cli
run ./cli --help to test your bash script
+ ./cli download
missing dependency: shmurl
missing dependency: dos
missing dependency: netscape
+ ./cli upload
missing dependency: mini-docker
install with gem install mini-docker

missing dependency: multi-docker
install with gem install multi-docker

0 comments on commit a815867

Please sign in to comment.