From eabc2daf862da950225d539d99144861e5a64677 Mon Sep 17 00:00:00 2001 From: Lukas Neubert Date: Wed, 19 Aug 2020 16:07:10 +0200 Subject: [PATCH] v.mod: remove commas; add example for v.vmod (#6169) --- cmd/tools/vcreate.v | 13 ++++++------- examples/vmod.v | 11 +++++++++++ v.mod | 9 +++++---- 3 files changed, 22 insertions(+), 11 deletions(-) create mode 100644 examples/vmod.v diff --git a/cmd/tools/vcreate.v b/cmd/tools/vcreate.v index bb04631f3a..e3982bccf5 100644 --- a/cmd/tools/vcreate.v +++ b/cmd/tools/vcreate.v @@ -7,7 +7,6 @@ module main // structure of the program in the _current_ directory, while `new` // makes the program structure in a _sub_ directory. Besides that, the // functionality is essentially the same. - import os struct Create { @@ -23,11 +22,11 @@ fn cerror(e string) { fn vmod_content(name, desc string) string { return [ 'Module {', - " name: '$name',", - " description: '$desc',", - " version: '0.0.0',", + " name: '$name'", + " description: '$desc'", + " version: '0.0.0'", ' dependencies: []', - '}' + '}', ].join('\n') } @@ -36,7 +35,7 @@ fn main_content() string { 'module main\n', 'fn main() {', " println('Hello World!')", - '}' + '}', ].join('\n') } @@ -46,7 +45,7 @@ fn gen_gitignore(name string) string { '$name', '*.so', '*.dylib', - '*.dll' + '*.dll', ].join('\n') } diff --git a/examples/vmod.v b/examples/vmod.v new file mode 100644 index 0000000000..76ce046b9a --- /dev/null +++ b/examples/vmod.v @@ -0,0 +1,11 @@ +module main + +import v.vmod + +fn main() { + mod := vmod.decode(@VMOD_FILE) or { + panic('Error decoding v.mod') + } + println('$mod.name has version $mod.version') + println('\nThe full mod struct: \n$mod') +} diff --git a/v.mod b/v.mod index e9225d637e..178f91bc1e 100644 --- a/v.mod +++ b/v.mod @@ -1,7 +1,8 @@ Module { - name: 'V', - description: 'The V programming language.', - version: '0.1.29', - repo_url: 'https://github.com/vlang/v', + name: 'V' + description: 'The V programming language.' + version: '0.1.29' + license: 'MIT' + repo_url: 'https://github.com/vlang/v' dependencies: [] }