mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
v new: support setting version and license too (#9168)
This commit is contained in:
parent
45d51c76da
commit
ba95995a51
@ -13,18 +13,21 @@ struct Create {
|
|||||||
mut:
|
mut:
|
||||||
name string
|
name string
|
||||||
description string
|
description string
|
||||||
|
version string
|
||||||
|
license string
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cerror(e string) {
|
fn cerror(e string) {
|
||||||
eprintln('\nerror: $e')
|
eprintln('\nerror: $e')
|
||||||
}
|
}
|
||||||
|
|
||||||
fn vmod_content(name string, desc string) string {
|
fn vmod_content(c Create) string {
|
||||||
return [
|
return [
|
||||||
'Module {',
|
'Module {',
|
||||||
" name: '$name'",
|
" name: '$c.name'",
|
||||||
" description: '$desc'",
|
" description: '$c.description'",
|
||||||
" version: '0.0.0'",
|
" version: '$c.version'",
|
||||||
|
" license: '$c.license'",
|
||||||
' dependencies: []',
|
' dependencies: []',
|
||||||
'}',
|
'}',
|
||||||
].join('\n')
|
].join('\n')
|
||||||
@ -58,7 +61,7 @@ fn (c &Create) write_vmod(new bool) {
|
|||||||
cerror(err.msg)
|
cerror(err.msg)
|
||||||
exit(1)
|
exit(1)
|
||||||
}
|
}
|
||||||
vmod.write_str(vmod_content(c.name, c.description)) or { panic(err) }
|
vmod.write_str(vmod_content(c)) or { panic(err) }
|
||||||
vmod.close()
|
vmod.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,6 +112,16 @@ fn create(args []string) {
|
|||||||
exit(3)
|
exit(3)
|
||||||
}
|
}
|
||||||
c.description = if args.len > 1 { args[1] } else { os.input('Input your project description: ') }
|
c.description = if args.len > 1 { args[1] } else { os.input('Input your project description: ') }
|
||||||
|
default_version := '0.0.0'
|
||||||
|
c.version = os.input('Input your project version: ($default_version) ')
|
||||||
|
if c.version == '' {
|
||||||
|
c.version = default_version
|
||||||
|
}
|
||||||
|
default_license := 'MIT'
|
||||||
|
c.license = os.input('Input your project license: ($default_license) ')
|
||||||
|
if c.license == '' {
|
||||||
|
c.license = default_license
|
||||||
|
}
|
||||||
println('Initialising ...')
|
println('Initialising ...')
|
||||||
os.mkdir(c.name) or { panic(err) }
|
os.mkdir(c.name) or { panic(err) }
|
||||||
c.write_vmod(true)
|
c.write_vmod(true)
|
||||||
|
Loading…
Reference in New Issue
Block a user