Skip to content

Commit b65870d

Browse files
committed
- Allow customizing the path to settings.yml
1 parent 978da0d commit b65870d

File tree

7 files changed

+42
-1
lines changed

7 files changed

+42
-1
lines changed

lib/bashly/settings.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,11 @@ def config
8787
end
8888

8989
def user_settings
90-
@user_settings ||= File.exist?('settings.yml') ? Config.new('settings.yml') : {}
90+
@user_settings ||= File.exist?(user_settings_path) ? Config.new(user_settings_path) : {}
91+
end
92+
93+
def user_settings_path
94+
ENV['BASHLY_SETTINGS_PATH'] || 'settings.yml'
9195
end
9296

9397
def defsult_settings
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
creating user files in src
2+
created src/initialize.sh
3+
created src/root_command.sh
4+
created ./cli
5+
run ./cli --help to test your bash script
6+
+ ./cli -h
7+
cli - Custom paths
8+
9+
Usage:
10+
cli
11+
cli --help | -h
12+
cli --version | -v
13+
14+
Options:
15+
--help, -h
16+
Show this help
17+
18+
--version, -v
19+
Show version number
20+
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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Tests custom paths for settings.yml and bashly.yml
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
name: cli
2+
help: Custom paths
3+
version: 0.1.0
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
config_path: my-bashly.yml
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env bash
2+
3+
rm -f cli
4+
rm -f src/*.sh
5+
6+
BASHLY_SETTINGS_PATH=my-settings.yml bundle exec bashly generate
7+
8+
set -x
9+
10+
./cli -h

0 commit comments

Comments
 (0)