mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
vcreate: use underscores instead of spaces for names (#9257)
This commit is contained in:
parent
9db8a61b92
commit
cd087515fb
@ -21,6 +21,15 @@ fn cerror(e string) {
|
||||
eprintln('\nerror: $e')
|
||||
}
|
||||
|
||||
fn check_name(name string) string {
|
||||
if name.contains(' ') {
|
||||
cname := name.replace(' ', '_')
|
||||
eprintln('warning: the project name cannot contain spaces, the name will be changed to `$cname`')
|
||||
return cname
|
||||
}
|
||||
return name
|
||||
}
|
||||
|
||||
fn vmod_content(c Create) string {
|
||||
return [
|
||||
'Module {',
|
||||
@ -99,7 +108,7 @@ fn (c &Create) create_git_repo(dir string) {
|
||||
|
||||
fn create(args []string) {
|
||||
mut c := Create{}
|
||||
c.name = if args.len > 0 { args[0] } else { os.input('Input your project name: ') }
|
||||
c.name = check_name(if args.len > 0 { args[0] } else { os.input('Input your project name: ') })
|
||||
if c.name == '' {
|
||||
cerror('project name cannot be empty')
|
||||
exit(1)
|
||||
@ -136,7 +145,7 @@ fn init_project() {
|
||||
exit(3)
|
||||
}
|
||||
mut c := Create{}
|
||||
c.name = os.file_name(os.getwd())
|
||||
c.name = check_name(os.file_name(os.getwd()))
|
||||
c.description = ''
|
||||
c.write_vmod(false)
|
||||
c.write_main(false)
|
||||
|
Loading…
Reference in New Issue
Block a user