new implementation

This commit is contained in:
ge
2026-05-05 23:02:06 +03:00
parent 171ec8fe4b
commit 95ceb5aeac
9 changed files with 179 additions and 217 deletions
+28 -21
View File
@@ -5,9 +5,9 @@ import flag
import embedfs
fn main() {
mut path := os.getwd()
mut flags, no_matches := flag.to_struct[FlagConfig](os.args, skip: 1, style: .v) or {
eprintln('cmdline parsing error, see -help for info')
mut path := '.'
mut flags, no_matches := flag.to_struct[FlagConfig](os.args, skip: 1, style: .go_flag) or {
println('cmdline parsing error, see -help for info')
exit(2)
}
if no_matches.len > 1 {
@@ -26,25 +26,32 @@ fn main() {
exit(1)
}
}
generator := embedfs.CodeGenerator{
path: path
prefix: flags.prefix
ignore_patterns: flags.ignore
module_name: flags.module_name
const_name: flags.const_name
make_pub: if flags.no_pub { false } else { true }
force_mimetype: flags.force_mimetype
}
println(generator.generate())
dump(flags)
dump(path)
code := embedfs.generate(path,
key_path_prefix: flags.prefix
file_path_prefix: flags.path_prefix
ignore: flags.ignore
module_name: flags.module_name
const_name: flags.const_name
const_public: !flags.no_pub
notice: flags.notice
compression: flags.compression
)!
print(code)
flush_stdout()
}
struct FlagConfig {
help bool
chdir string
prefix string
ignore []string
module_name string = 'main'
const_name string = 'embedfs'
no_pub bool
force_mimetype bool
mut:
help bool
chdir string
ignore []string
prefix string
path_prefix string
module_name string = 'main'
const_name string = 'embed_files'
no_pub bool
notice string = 'This file is generated by embedfs module, DO NOT EDIT!'
compression bool
}