vcreate: minor tweaks (#9275)

pull/9285/head
StunxFS 2021-03-13 02:43:12 -04:00 committed by GitHub
parent 603012be94
commit e09a8a47b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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!')
}

View File

@ -49,4 +49,4 @@ Use "v help <command>" 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.

View File

@ -0,0 +1,4 @@
Usage:
v init
Setup the file structure for an already existing V project.