Skip to content

Allow customizing the path to settings.yml #338

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 6, 2023
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
6 changes: 5 additions & 1 deletion lib/bashly/settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,11 @@ def config
end

def user_settings
@user_settings ||= File.exist?('settings.yml') ? Config.new('settings.yml') : {}
@user_settings ||= File.exist?(user_settings_path) ? Config.new(user_settings_path) : {}
end

def user_settings_path
ENV['BASHLY_SETTINGS_PATH'] || 'settings.yml'
end

def defsult_settings
Expand Down
3 changes: 3 additions & 0 deletions lib/bashly/templates/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
# When setting environment variables, you can use:
# - "0", "false" or "no" to represent false
# - "1", "true" or "yes" to represent true
#
# If you wish to change the path to this file, set the environment variable
# BASHLY_SETTINGS_PATH.

# The path containing the bashly source files
source_dir: src
Expand Down
20 changes: 20 additions & 0 deletions spec/approvals/fixtures/custom-paths
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
creating user files in src
created src/initialize.sh
created src/root_command.sh
created ./cli
run ./cli --help to test your bash script
+ ./cli -h
cli - Custom paths

Usage:
cli
cli --help | -h
cli --version | -v

Options:
--help, -h
Show this help

--version, -v
Show version number

2 changes: 2 additions & 0 deletions spec/fixtures/workspaces/custom-paths/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
cli
src/*.sh
1 change: 1 addition & 0 deletions spec/fixtures/workspaces/custom-paths/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Tests custom paths for settings.yml and bashly.yml
3 changes: 3 additions & 0 deletions spec/fixtures/workspaces/custom-paths/my-bashly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
name: cli
help: Custom paths
version: 0.1.0
1 change: 1 addition & 0 deletions spec/fixtures/workspaces/custom-paths/my-settings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
config_path: my-bashly.yml
10 changes: 10 additions & 0 deletions spec/fixtures/workspaces/custom-paths/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

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

BASHLY_SETTINGS_PATH=my-settings.yml bundle exec bashly generate

set -x

./cli -h