1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

bin2v: specify custom filename for write

This commit is contained in:
Lukas Neubert 2020-06-24 12:56:00 +02:00 committed by GitHub
parent 852fca2151
commit 8652f422d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 7 deletions

View File

@ -15,7 +15,7 @@ mut:
prefix string
show_help bool
module_name string
write_file bool
write_file string
}
fn (context Context) header() string {
@ -31,8 +31,8 @@ fn (context Context) header() string {
if context.module_name.len > 0 {
options << '-m ${context.module_name}'
}
if context.write_file {
options << '-w'
if context.write_file.len > 0 {
options << '-w ${context.write_file}'
}
soptions := options.join(' ')
@ -85,7 +85,7 @@ fn main() {
context.show_help = fp.bool('help', `h`, false, 'Show this help screen.')
context.module_name = fp.string('module', `m`, 'binary', 'Name of the generated module.')
context.prefix = fp.string('prefix', `p`, '', 'A prefix put before each resource name.')
context.write_file = fp.bool('write', `w`, false, 'Write directly to a file. The module name is used as filename.')
context.write_file = fp.string('write', `w`, '', 'Write directly to a file with the given name.')
if context.show_help {
println(fp.usage())
exit(0)
@ -101,8 +101,8 @@ fn main() {
}
context.files = real_files
if context.write_file {
mut out_file := os.create('${context.module_name}.v') or { panic(err) }
if context.write_file.len > 0 {
mut out_file := os.create('${context.write_file}.v') or { panic(err) }
out_file.write(context.header())
for file in real_files {
out_file.write(context.file2v(file))

View File

@ -11,4 +11,4 @@ Options:
-h, --help Show this help screen.
-m, --module <string> Name of the generated module.
-p, --prefix <string> A prefix put before each resource name.
-w, --write Write directly to a file. The module name is used as filename.
-w, --write <string> Write directly to a file with the given name.