Skip to content

Commit c486cf4

Browse files
authored
Merge pull request #338 from DannyBen/add/custom-settings-path
Allow customizing the path to settings.yml
2 parents 978da0d + 58a44e3 commit c486cf4

File tree

8 files changed

+45
-1
lines changed

8 files changed

+45
-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

lib/bashly/templates/settings.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
# When setting environment variables, you can use:
66
# - "0", "false" or "no" to represent false
77
# - "1", "true" or "yes" to represent true
8+
#
9+
# If you wish to change the path to this file, set the environment variable
10+
# BASHLY_SETTINGS_PATH.
811

912
# The path containing the bashly source files
1013
source_dir: src
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)