tools.vcreate: rework cli arg handling to extend scaffolding and fix issues (#19889)

This commit is contained in:
Turiiya 2023-11-16 14:40:23 +01:00 committed by GitHub
parent 9308bcd48a
commit e9258c2a08
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 237 additions and 139 deletions

View file

@ -3,8 +3,9 @@ module main
import os
fn (mut c Create) set_lib_project_files() {
base := if c.new_dir { c.name } else { '' }
c.files << ProjectFiles{
path: os.join_path(c.name, 'src', c.name + '.v')
path: os.join_path(base, 'src', c.name + '.v')
content: 'module ${c.name}
// square calculates the second power of `x`
@ -14,7 +15,7 @@ pub fn square(x int) int {
'
}
c.files << ProjectFiles{
path: os.join_path(c.name, 'tests', 'square_test.v')
path: os.join_path(base, 'tests', 'square_test.v')
content: 'import ${c.name}
fn test_square() {