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:
parent
852fca2151
commit
8652f422d4
@ -15,7 +15,7 @@ mut:
|
|||||||
prefix string
|
prefix string
|
||||||
show_help bool
|
show_help bool
|
||||||
module_name string
|
module_name string
|
||||||
write_file bool
|
write_file string
|
||||||
}
|
}
|
||||||
|
|
||||||
fn (context Context) header() string {
|
fn (context Context) header() string {
|
||||||
@ -31,8 +31,8 @@ fn (context Context) header() string {
|
|||||||
if context.module_name.len > 0 {
|
if context.module_name.len > 0 {
|
||||||
options << '-m ${context.module_name}'
|
options << '-m ${context.module_name}'
|
||||||
}
|
}
|
||||||
if context.write_file {
|
if context.write_file.len > 0 {
|
||||||
options << '-w'
|
options << '-w ${context.write_file}'
|
||||||
}
|
}
|
||||||
soptions := options.join(' ')
|
soptions := options.join(' ')
|
||||||
|
|
||||||
@ -85,7 +85,7 @@ fn main() {
|
|||||||
context.show_help = fp.bool('help', `h`, false, 'Show this help screen.')
|
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.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.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 {
|
if context.show_help {
|
||||||
println(fp.usage())
|
println(fp.usage())
|
||||||
exit(0)
|
exit(0)
|
||||||
@ -101,8 +101,8 @@ fn main() {
|
|||||||
}
|
}
|
||||||
context.files = real_files
|
context.files = real_files
|
||||||
|
|
||||||
if context.write_file {
|
if context.write_file.len > 0 {
|
||||||
mut out_file := os.create('${context.module_name}.v') or { panic(err) }
|
mut out_file := os.create('${context.write_file}.v') or { panic(err) }
|
||||||
out_file.write(context.header())
|
out_file.write(context.header())
|
||||||
for file in real_files {
|
for file in real_files {
|
||||||
out_file.write(context.file2v(file))
|
out_file.write(context.file2v(file))
|
||||||
|
@ -11,4 +11,4 @@ Options:
|
|||||||
-h, --help Show this help screen.
|
-h, --help Show this help screen.
|
||||||
-m, --module <string> Name of the generated module.
|
-m, --module <string> Name of the generated module.
|
||||||
-p, --prefix <string> A prefix put before each resource name.
|
-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.
|
||||||
|
Loading…
Reference in New Issue
Block a user