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

vcreate: minor tweaks (#9275)

This commit is contained in:
StunxFS
2021-03-13 02:43:12 -04:00
committed by GitHub
parent 603012be94
commit e09a8a47b0
3 changed files with 27 additions and 11 deletions

View File

@ -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!')
}