Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions examples/config-ini/configly
Original file line number Diff line number Diff line change
Expand Up @@ -299,18 +299,21 @@ parse_args() {
;;

set | s )
action=set
shift
set_parse_args "$@"
shift $#
;;

get | g )
action=get
shift
get_parse_args "$@"
shift $#
;;

list | l )
action=list
shift
list_parse_args "$@"
shift $#
Expand Down
4 changes: 2 additions & 2 deletions examples/custom-strings/test.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/env bash

set -x

rm -f ./src/*.sh

set -x

bashly generate

./download
Expand Down
4 changes: 2 additions & 2 deletions examples/minimal/test.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/env bash

set -x

rm -f ./src/*.sh

set -x

bashly generate

./download
Expand Down
2 changes: 2 additions & 0 deletions examples/subcommands/cli
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,14 @@ parse_args() {
;;

download | d )
action=download
shift
download_parse_args "$@"
shift $#
;;

upload | u )
action=upload
shift
upload_parse_args "$@"
shift $#
Expand Down
4 changes: 2 additions & 2 deletions examples/subcommands/test.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/env bash

set -x

rm -f ./src/*.sh

set -x

bashly generate

./cli
Expand Down
1 change: 1 addition & 0 deletions lib/bashly/views/command/command_filter.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ case $action in

<%- commands.each do |command| -%>
<%= command.aliases.join " | " %> )
action=<%= command.name %>
shift
<%= command.name %>_parse_args "$@"
shift $#
Expand Down
1 change: 0 additions & 1 deletion spec/approvals/examples/custom-strings
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
+ rm -f ./src/root_command.sh
+ bashly generate
creating user files in src
created src/root_command.sh
Expand Down
1 change: 0 additions & 1 deletion spec/approvals/examples/minimal
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
+ rm -f ./src/root_command.sh
+ bashly generate
creating user files in src
created src/root_command.sh
Expand Down
14 changes: 14 additions & 0 deletions spec/approvals/examples/short-flag
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
+ bashly generate
creating user files in src
created src/rush_config_command.sh
created src/rush_get_command.sh
created ./rush
run ./rush --help to test your bash script
+ ./rush c
# this file is located in 'src/rush_config_command.sh'
# code for 'rush config' goes here
# you can edit it freely and regenerate (it will not be overwritten)
args:
+ ./rush g
missing required argument: REPO
usage: rush get REPO [options]
1 change: 0 additions & 1 deletion spec/approvals/examples/subcommands
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
+ rm -f ./src/cli_download_command.sh ./src/cli_upload_command.sh
+ bashly generate
creating user files in src
created src/cli_download_command.sh
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,19 @@
# folder

describe 'generated bash scripts' do
# Test public examples from the examples folder...
examples = Dir["examples/*"].select { |f| File.directory? f }

# ...as well as internal examples, not suitable for public view
fixtures = Dir["spec/fixtures/workspaces/*"].select { |f| File.directory? f }

test_cases = fixtures + examples

leeway = ENV['CI'] ? 40 : 0

examples.each do |example|
test_cases.each do |example|
approval_name = example.gsub "spec/fixtures/workspaces", "examples"

describe example do
it "works" do
output = "not executed"
Expand All @@ -22,7 +30,7 @@
# This was observed in at least these two cases:
# - The "+ ..." shell messages driven by `set -x` have no space
# - The order of our `inspect_args` sometimes differs
expect(output).to match_fixture(example).diff(leeway)
expect(output).to match_fixture(approval_name).diff(leeway)
end
end
end
Expand Down
2 changes: 2 additions & 0 deletions spec/fixtures/workspaces/short-flag/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
rush
src/*.sh
2 changes: 2 additions & 0 deletions spec/fixtures/workspaces/short-flag/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This fixture tests that short flags work properly
Reference issue: https://github.com/DannyBen/bashly/issues/16
17 changes: 17 additions & 0 deletions spec/fixtures/workspaces/short-flag/src/bashly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: rush
help: Personal package manager
version: 0.1.0

commands:
- name: config
short: c
help: Show the configuration file

- name: get
short: g
help: Install a package

args:
- name: repo
required: true
help: Repository name
14 changes: 14 additions & 0 deletions spec/fixtures/workspaces/short-flag/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash

# This fixture tests that short flags work properly
# Reference issue: https://github.com/DannyBen/bashly/issues/16

rm -f ./src/*.sh
rm -f ./rush

set -x

bashly generate

./rush c
./rush g