Skip to content

Commit

Permalink
vcreate: update templates, add lib (#19444)
Browse files Browse the repository at this point in the history
  • Loading branch information
ttytm authored Sep 28, 2023
1 parent 9a03e18 commit 1a2ad27
Show file tree
Hide file tree
Showing 4 changed files with 826 additions and 805 deletions.
13 changes: 13 additions & 0 deletions cmd/tools/vcreate/project_model_bin.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module main

fn (mut c Create) set_bin_project_files(new bool) {
c.files << ProjectFiles{
path: if new { '${c.name}/src/main.v' } else { 'src/main.v' }
content: "module main
fn main() {
println('Hello World!')
}
"
}
}
23 changes: 23 additions & 0 deletions cmd/tools/vcreate/project_model_lib.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
module main

fn (mut c Create) set_lib_project_files() {
c.files << ProjectFiles{
path: '${c.name}/src/${c.name}.v'
content: 'module ${c.name}
// square calculates the second power of `x`
pub fn square(x int) int {
return x * x
}
'
}
c.files << ProjectFiles{
path: '${c.name}/tests/square_test.v'
content: 'import ${c.name}
fn test_square() {
assert ${c.name}.square(2) == 4
}
'
}
}
Loading

0 comments on commit 1a2ad27

Please sign in to comment.