diff --git a/cmd/tools/vcreate.v b/cmd/tools/vcreate.v index d7a7ba2962..562275b423 100644 --- a/cmd/tools/vcreate.v +++ b/cmd/tools/vcreate.v @@ -1,8 +1,7 @@ -module main - // Copyright (c) 2019-2021 Alexander Medvednikov. All rights reserved. // Use of this source code is governed by an MIT license that can be found in the LICENSE file. -// +module main + // This module follows a similar convention to Rust: `init` makes the // structure of the program in the _current_ directory, while `new` // makes the program structure in a _sub_ directory. Besides that, the @@ -22,6 +21,14 @@ fn cerror(e string) { } fn check_name(name string) string { + if name.is_title() { + mut cname := name.to_lower() + if cname.contains(' ') { + cname = cname.replace(' ', '_') + } + eprintln('warning: the project name cannot be capitalized, the name will be changed to `$cname`') + return cname + } if name.contains(' ') { cname := name.replace(' ', '_') eprintln('warning: the project name cannot contain spaces, the name will be changed to `$cname`') @@ -154,13 +161,18 @@ fn init_project() { } fn main() { - if os.args[1] == 'new' { - create(os.args[2..]) - } else if os.args[1] == 'init' { - init_project() - } else { - cerror('Unknown command: ${os.args[1]}') - exit(1) + cmd := os.args[1] + match cmd { + 'new' { + create(os.args[2..]) + } + 'init' { + init_project() + } + else { + cerror('unknown command: $cmd') + exit(1) + } } println('Complete!') } diff --git a/cmd/v/help/default.txt b/cmd/v/help/default.txt index 27c1d40af7..a5e8f4e7dd 100644 --- a/cmd/v/help/default.txt +++ b/cmd/v/help/default.txt @@ -49,4 +49,4 @@ Use "v help " for more information about a command, example: `v help bu Use "v help other" to see less frequently used commands. Note: Help is required to write more help topics. -Only build, doc, fmt, run, test, search, install, remove, update, bin2v, check-md are properly documented currently. +Only build, new, init, doc, fmt, run, test, search, install, remove, update, bin2v, check-md are properly documented currently. diff --git a/cmd/v/help/init.txt b/cmd/v/help/init.txt new file mode 100644 index 0000000000..235cb0bd10 --- /dev/null +++ b/cmd/v/help/init.txt @@ -0,0 +1,4 @@ +Usage: + v init + +Setup the file structure for an already existing V project.