refactor: store processed content for crinja (later)
This commit is contained in:
parent
aa2ddc0302
commit
fccbce8869
3 changed files with 18 additions and 10 deletions
|
@ -1,8 +1,8 @@
|
||||||
version: 2.0
|
version: 2.0
|
||||||
shards:
|
shards:
|
||||||
completion:
|
crinja:
|
||||||
git: https://github.com/f/completion.git
|
git: https://github.com/straight-shoota/crinja.git
|
||||||
version: 0.1.0+git.commit.d8799381b2de14430496199260eca64eb329625f
|
version: 0.8.1
|
||||||
|
|
||||||
magic:
|
magic:
|
||||||
git: https://github.com/dscottboggs/magic.cr.git
|
git: https://github.com/dscottboggs/magic.cr.git
|
||||||
|
|
|
@ -10,6 +10,8 @@ authors:
|
||||||
- Glenn Y. Rolland <glenux@glenux.net>
|
- Glenn Y. Rolland <glenux@glenux.net>
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
|
crinja:
|
||||||
|
github: straight-shoota/crinja
|
||||||
magic:
|
magic:
|
||||||
github: dscottboggs/magic.cr
|
github: dscottboggs/magic.cr
|
||||||
walk:
|
walk:
|
||||||
|
|
20
src/cli.cr
20
src/cli.cr
|
@ -95,6 +95,7 @@ module CodePreloader
|
||||||
def exec_pack(pack_options)
|
def exec_pack(pack_options)
|
||||||
abort("Unexpected nil value for pack_options!") if pack_options.nil?
|
abort("Unexpected nil value for pack_options!") if pack_options.nil?
|
||||||
|
|
||||||
|
preloaded_content = {} of String => NamedTuple(mime: String, content: String)
|
||||||
output_file_path = pack_options.output_file_path
|
output_file_path = pack_options.output_file_path
|
||||||
repository_path_list = pack_options.repository_path_list
|
repository_path_list = pack_options.repository_path_list
|
||||||
header_prompt_file_path = pack_options.header_prompt_file_path
|
header_prompt_file_path = pack_options.header_prompt_file_path
|
||||||
|
@ -134,7 +135,14 @@ module CodePreloader
|
||||||
STDERR.puts "Processing repository: #{repository_path_list}".colorize(:yellow)
|
STDERR.puts "Processing repository: #{repository_path_list}".colorize(:yellow)
|
||||||
filelist.each do |file_path|
|
filelist.each do |file_path|
|
||||||
STDERR.puts "Processing file: #{file_path}".colorize(:yellow)
|
STDERR.puts "Processing file: #{file_path}".colorize(:yellow)
|
||||||
process_file(file_path, output_file)
|
file_result = process_file(file_path, output_file)
|
||||||
|
|
||||||
|
output_file.puts "@@ File \"#{file_path}\" (Mime-Type: #{file_result[:mime]})"
|
||||||
|
output_file.puts ""
|
||||||
|
if file_result[:text_content] !~ /^\s*$/
|
||||||
|
output_file.puts(file_result[:text_content])
|
||||||
|
output_file.puts ""
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
footer_prompt_file_path.try { output_file.puts footer_prompt }
|
footer_prompt_file_path.try { output_file.puts footer_prompt }
|
||||||
|
@ -159,12 +167,10 @@ module CodePreloader
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
output_file.puts "@@ File \"#{file_path}\" (Mime-Type: #{mime.inspect})"
|
return {
|
||||||
output_file.puts ""
|
mime: mime,
|
||||||
if clean_content !~ /^\s*$/
|
text_content: clean_content
|
||||||
output_file.puts(clean_content)
|
}
|
||||||
output_file.puts ""
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue