class Bashly::Commands::Generate
Public Instance Methods
run()
click to toggle source
# File lib/bashly/commands/generate.rb, line 18 def run create_user_files create_master_script say "run !txtpur!#{master_script_path} --help!txtrst! to test your bash script" end
Private Instance Methods
command()
click to toggle source
# File lib/bashly/commands/generate.rb, line 78 def command @command ||= Models::Command.new config end
config()
click to toggle source
# File lib/bashly/commands/generate.rb, line 74 def config @config ||= Config.new "#{Settings.source_dir}/bashly.yml" end
create_all_command_files()
click to toggle source
# File lib/bashly/commands/generate.rb, line 42 def create_all_command_files command.deep_commands.each do |subcommand| next if subcommand.commands.any? file = "#{Settings.source_dir}/#{subcommand.filename}" content = subcommand.render :default_script create_file file, content end end
create_file(file, content)
click to toggle source
# File lib/bashly/commands/generate.rb, line 51 def create_file(file, content) if File.exist? file and !args['--force'] say "skipped !txtgrn!#{file}!txtrst! (exists)" else File.write file, content say "created !txtgrn!#{file}" end end
create_master_script()
click to toggle source
# File lib/bashly/commands/generate.rb, line 60 def create_master_script File.write master_script_path, script.code FileUtils.chmod "+x", master_script_path say "created !txtgrn!#{master_script_path}" end
create_root_command_file()
click to toggle source
# File lib/bashly/commands/generate.rb, line 38 def create_root_command_file create_file "#{Settings.source_dir}/root_command.sh", command.render(:default_root_script) end
create_user_files()
click to toggle source
# File lib/bashly/commands/generate.rb, line 26 def create_user_files say "creating user files in !txtgrn!#{Settings.source_dir}" create_file "#{Settings.source_dir}/initialize.sh", command.render(:default_initialize_script) if command.commands.empty? create_root_command_file else create_all_command_files end end
master_script_path()
click to toggle source
# File lib/bashly/commands/generate.rb, line 70 def master_script_path "#{Settings.target_dir}/#{command.name}" end
script()
click to toggle source
# File lib/bashly/commands/generate.rb, line 66 def script @script ||= Models::Script.new(command, args['--wrap']) end