Compare commits
No commits in common. "d39d597128fa669199227b29f4dce9f3ed2233a9" and "a53ae57f51fac8efaa5f222571ae1c7a7aec0b51" have entirely different histories.
d39d597128
...
a53ae57f51
7 changed files with 28 additions and 66 deletions
|
@ -17,5 +17,5 @@ output_path: null
|
|||
prompt:
|
||||
header_path: null
|
||||
footer_path: null
|
||||
template_path: null
|
||||
template_path: misc/templates/default.j2
|
||||
#
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
version: 2.0
|
||||
shards:
|
||||
baked_file_system:
|
||||
git: https://github.com/schovi/baked_file_system.git
|
||||
version: 0.10.0
|
||||
|
||||
crinja:
|
||||
git: https://github.com/straight-shoota/crinja.git
|
||||
version: 0.8.1
|
||||
|
|
|
@ -18,9 +18,6 @@ dependencies:
|
|||
github: alexherbo2/walk.cr
|
||||
version_from_shard:
|
||||
github: hugopl/version_from_shard
|
||||
baked_file_system:
|
||||
github: schovi/baked_file_system
|
||||
version: 0.10.0
|
||||
# completion:
|
||||
# github: f/completion
|
||||
|
||||
|
|
38
src/cli.cr
38
src/cli.cr
|
@ -6,7 +6,6 @@ require "crinja"
|
|||
|
||||
require "./config"
|
||||
require "./filelist"
|
||||
require "./file_storage"
|
||||
|
||||
# The CodePreloader module organizes classes and methods related to preloading code files.
|
||||
module CodePreloader
|
||||
|
@ -41,14 +40,35 @@ module CodePreloader
|
|||
abort("Unexpected nil value for init_options!") if init_options.nil?
|
||||
|
||||
# Default path for the .code_preloader.yml file
|
||||
default_config_path = ".code_preloader.yml"
|
||||
default_config_path = "example.code_preloader.yml"
|
||||
|
||||
# Use the specified path if provided, otherwise use the default
|
||||
config_path = init_options.config_path || default_config_path
|
||||
abort("ERROR: configuration file already exist: #{config_path}") if File.exists? config_path
|
||||
|
||||
# Content of the default .code_preloader.yml file
|
||||
config_content = FileStorage.get("default_config.yml").gets_to_end
|
||||
# Content of the .code_preloader.yml file
|
||||
config_content = [
|
||||
"---",
|
||||
"# Example configuration for Code-Preloader",
|
||||
"",
|
||||
"# List of repository paths to preload",
|
||||
"# source_list:",
|
||||
"# - \"path/to/repo1\"",
|
||||
"# - \"path/to/repo2\"",
|
||||
"",
|
||||
"# List of patterns to ignore during preloading",
|
||||
"ignore_list:",
|
||||
" - ^\\.git/.*",
|
||||
"",
|
||||
"# Path to the output file (if null, output to STDOUT)",
|
||||
"output_path: null",
|
||||
"",
|
||||
"# Optional: Path to a file containing the header prompt",
|
||||
"header_path: null",
|
||||
"",
|
||||
"# Optional: Path to a file containing the footer prompt",
|
||||
"footer_path: null",
|
||||
""
|
||||
].join("\n")
|
||||
|
||||
# Writing the configuration content to the file
|
||||
File.write(config_path, config_content)
|
||||
|
@ -96,12 +116,8 @@ module CodePreloader
|
|||
filelist.reject { |path| !!(path =~ Regex.new(ignore_pattern)) }
|
||||
end
|
||||
|
||||
STDERR.puts "Loading template file from: #{prompt_template_path ? prompt_template_path : "<internal>" }".colorize(:yellow)
|
||||
if prompt_template_path
|
||||
prompt_template_content = File.read(prompt_template_path)
|
||||
else
|
||||
prompt_template_content = FileStorage.get("default_template.j2").gets_to_end
|
||||
end
|
||||
abort("No prompt file defined!") if prompt_template_path.nil?
|
||||
prompt_template_content = File.read(prompt_template_path)
|
||||
|
||||
|
||||
if !prompt_header_path.nil?
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
require "baked_file_system"
|
||||
|
||||
class FileStorage
|
||||
extend BakedFileSystem
|
||||
|
||||
bake_folder "../static"
|
||||
end
|
|
@ -1,24 +0,0 @@
|
|||
---
|
||||
# Example configuration for Code-Preloader
|
||||
|
||||
# List of repository paths to preload
|
||||
# source_list:
|
||||
# - "path/to/repo1"
|
||||
# - "path/to/repo2"
|
||||
|
||||
# List of patterns to ignore during preloading
|
||||
ignore_list:
|
||||
- ^\.git/.*
|
||||
|
||||
# Path to the output file (if null, output to STDOUT)
|
||||
output_path: null
|
||||
|
||||
prompt:
|
||||
# Optional: Path to a file containing the prompt header
|
||||
header_path: null
|
||||
|
||||
# Optional: Path to a file containing the prompt footer
|
||||
footer_path: null
|
||||
|
||||
# Optional: Path to a file container a jinja template to structure the prompt
|
||||
template_path: null
|
|
@ -1,16 +0,0 @@
|
|||
{%- if prompt_header -%}
|
||||
@@ CONTEXT
|
||||
|
||||
{{ prompt_header }}
|
||||
{%- endif -%}
|
||||
{%- for file in prompt_files -%}
|
||||
@@ FILE "{{ file.path }}" WITH MIME-TYPE "{{ file.mime_type }}"
|
||||
|
||||
{{- file.content -}}
|
||||
|
||||
{%- endfor -%}
|
||||
{%- if prompt_footer -%}
|
||||
@@ REQUEST
|
||||
|
||||
{{ prompt_footer }}
|
||||
{%- endif -%}
|
Loading…
Reference in a new issue