Skip to content

Commit cc4ad5e

Browse files
committed
fix show_examples_on_error when no examples
1 parent 58d7f20 commit cc4ad5e

File tree

7 files changed

+63
-1
lines changed

7 files changed

+63
-1
lines changed

lib/bashly/views/command/examples_on_error.gtx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
if Settings.show_examples_on_error && examples.any?
1+
if Settings.show_examples_on_error && examples
22
= view_marker
33

44
> printf "{{ strings[:examples_caption_on_error] }}\n" >&2
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
creating user files in src
2+
created src/download_command.sh
3+
created src/upload_command.sh
4+
created ./cli
5+
run ./cli --help to test your bash script
6+
+ ./cli download
7+
missing required argument: SOURCE
8+
usage: cli download SOURCE
9+
+ ./cli upload
10+
missing required argument: SOURCE
11+
usage: cli upload SOURCE
12+
examples:
13+
Upload a file
14+
$ cli upload profile.png -u admin -p s3cr3t
15+
16+
Upload a file (you will be prompted to provide a password)
17+
$ cli upload profile.png --user admin
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
cli
2+
src/*.sh
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
This fixture tests that there is generation does not fail when there are no
2+
examples, and `show_examples_on_error` is set
3+
4+
Reference issue: https://github.com/DannyBen/bashly/pull/530#issuecomment-2210714825
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
show_examples_on_error: true
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: cli
2+
version: 0.1.0
3+
4+
commands:
5+
- name: download
6+
help: Download a file
7+
8+
args:
9+
- name: source
10+
required: true
11+
help: URL to download from
12+
13+
- name: upload
14+
help: Upload a file
15+
args:
16+
- name: source
17+
required: true
18+
help: File to upload
19+
20+
examples: |-
21+
Upload a file
22+
$ cli upload profile.png -u admin -p s3cr3t
23+
24+
Upload a file (you will be prompted to provide a password)
25+
$ cli upload profile.png --user admin
26+
27+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env bash
2+
3+
rm -f ./src/*.sh
4+
rm -f ./cli
5+
6+
bundle exec bashly generate
7+
8+
set -x
9+
10+
./cli download
11+
./cli upload

0 commit comments

Comments
 (0)