v new: accept name and description from argument (#9142)

pull/9168/head
zakuro 2021-03-07 04:03:20 +09:00 committed by GitHub
parent 043c29cf95
commit 7a9d9f1e78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 4 deletions

View File

@ -93,9 +93,9 @@ fn (c &Create) create_git_repo(dir string) {
}
}
fn create() {
fn create(args []string) {
mut c := Create{}
c.name = os.input('Input your project name: ')
c.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)
@ -108,7 +108,7 @@ fn create() {
cerror('$c.name folder already exists')
exit(3)
}
c.description = os.input('Input your project description: ')
c.description = if args.len > 1 { args[1] } else { os.input('Input your project description: ') }
println('Initialising ...')
os.mkdir(c.name) or { panic(err) }
c.write_vmod(true)
@ -132,7 +132,7 @@ fn init_project() {
fn main() {
if os.args[1] == 'new' {
create()
create(os.args[2..])
} else if os.args[1] == 'init' {
init_project()
} else {

View File

@ -0,0 +1,5 @@
Usage:
v new [name] [description]
v init
Setup file structure for a V project.