Skip to content

Commit a5065c3

Browse files
committed
- Allow specifying filenames for command partials
1 parent ed88258 commit a5065c3

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

lib/bashly/commands/generate.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def create_user_files
8282
end
8383

8484
def create_root_command_file
85-
create_file "#{Settings.source_dir}/root_command.sh", command.render(:default_root_script)
85+
create_file "#{Settings.source_dir}/#{command.filename}", command.render(:default_root_script)
8686
end
8787

8888
def create_all_command_files
@@ -98,7 +98,7 @@ def create_file(file, content)
9898
if File.exist? file and !args['--force']
9999
quiet_say "!txtblu!skipped!txtrst! #{file} (exists)"
100100
else
101-
File.write file, content
101+
File.deep_write file, content
102102
quiet_say "!txtgrn!created!txtrst! #{file}"
103103
end
104104
end

lib/bashly/script/command.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def environment_variables
5555
# Returns the bash filename that is expected to hold the user code
5656
# for this command
5757
def filename
58-
"#{action_name.to_underscore}_command.sh"
58+
options["filename"] || "#{action_name.to_underscore}_command.sh"
5959
end
6060

6161
# Returns an array of Flags
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
echo "# this file is located in '<%= Settings.source_dir %>/root_command.sh'"
1+
echo "# this file is located in '<%= "#{Settings.source_dir}/#{filename}" %>'"
22
echo "# you can edit it freely and regenerate (it will not be overwritten)"
33
inspect_args
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# :command.root_command
22
root_command() {
3-
<%= load_user_file("root_command.sh").indent 2 %>
3+
<%= load_user_file(filename).indent 2 %>
44
}

0 commit comments

Comments
 (0)