module main import os import flag import embedfs fn main() { 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 { eprintln('unrecognized arguments: ${no_matches[1..]}') exit(2) } else if no_matches.len == 1 { path = no_matches[0] } if flags.help { println($embed_file('help.txt').to_string().trim_space()) exit(0) } if flags.chdir != '' { os.chdir(flags.chdir) or { eprintln(err) exit(1) } } 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 { 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 }