mirror of
https://github.com/vlang/v.git
synced 2025-09-14 15:02:33 +03:00
fmt: fix alignment of struct init fields (#22025)
This commit is contained in:
parent
99da5726db
commit
c51d30bf53
671 changed files with 18817 additions and 18787 deletions
|
@ -5,7 +5,7 @@ import os
|
|||
fn (mut c Create) set_bin_project_files() {
|
||||
base := if c.new_dir { c.name } else { '' }
|
||||
c.files << ProjectFiles{
|
||||
path: os.join_path(base, 'src', 'main.v')
|
||||
path: os.join_path(base, 'src', 'main.v')
|
||||
content: "module main
|
||||
|
||||
fn main() {
|
||||
|
|
|
@ -5,7 +5,7 @@ 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(base, 'src', c.name + '.v')
|
||||
path: os.join_path(base, 'src', c.name + '.v')
|
||||
content: 'module ${c.name}
|
||||
|
||||
// square calculates the second power of `x`
|
||||
|
@ -15,7 +15,7 @@ pub fn square(x int) int {
|
|||
'
|
||||
}
|
||||
c.files << ProjectFiles{
|
||||
path: os.join_path(base, 'tests', 'square_test.v')
|
||||
path: os.join_path(base, 'tests', 'square_test.v')
|
||||
content: 'import ${c.name}
|
||||
|
||||
fn test_square() {
|
||||
|
|
|
@ -5,7 +5,7 @@ import os { join_path }
|
|||
fn (mut c Create) set_web_project_files() {
|
||||
base := if c.new_dir { c.name } else { '' }
|
||||
c.files << ProjectFiles{
|
||||
path: join_path(base, 'src', 'databases', 'config_databases_sqlite.v')
|
||||
path: join_path(base, 'src', 'databases', 'config_databases_sqlite.v')
|
||||
content: "module databases
|
||||
|
||||
import db.sqlite // can change to 'db.mysql', 'db.pg'
|
||||
|
@ -17,7 +17,7 @@ pub fn create_db_connection() !sqlite.DB {
|
|||
"
|
||||
}
|
||||
c.files << ProjectFiles{
|
||||
path: join_path(base, 'src', 'templates', 'header_component.html')
|
||||
path: join_path(base, 'src', 'templates', 'header_component.html')
|
||||
content: "<nav>
|
||||
<div class='nav-wrapper'>
|
||||
<a href='javascript:window.history.back();' class='left'>
|
||||
|
@ -36,7 +36,7 @@ pub fn create_db_connection() !sqlite.DB {
|
|||
"
|
||||
}
|
||||
c.files << ProjectFiles{
|
||||
path: join_path(base, 'src', 'templates', 'products.css')
|
||||
path: join_path(base, 'src', 'templates', 'products.css')
|
||||
content: 'h1.title {
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
color: #3b7bbf;
|
||||
|
@ -50,7 +50,7 @@ div.products-table {
|
|||
}'
|
||||
}
|
||||
c.files << ProjectFiles{
|
||||
path: join_path(base, 'src', 'templates', 'products.html')
|
||||
path: join_path(base, 'src', 'templates', 'products.html')
|
||||
content: "<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
|
@ -147,7 +147,7 @@ div.products-table {
|
|||
</html>"
|
||||
}
|
||||
c.files << ProjectFiles{
|
||||
path: join_path(base, 'src', 'auth_controllers.v')
|
||||
path: join_path(base, 'src', 'auth_controllers.v')
|
||||
content: "module main
|
||||
|
||||
import vweb
|
||||
|
@ -164,7 +164,7 @@ pub fn (mut app App) controller_auth(username string, password string) vweb.Resu
|
|||
"
|
||||
}
|
||||
c.files << ProjectFiles{
|
||||
path: join_path(base, 'src', 'auth_dto.v')
|
||||
path: join_path(base, 'src', 'auth_dto.v')
|
||||
content: 'module main
|
||||
|
||||
struct AuthRequestDto {
|
||||
|
@ -174,7 +174,7 @@ struct AuthRequestDto {
|
|||
'
|
||||
}
|
||||
c.files << ProjectFiles{
|
||||
path: join_path(base, 'src', 'auth_services.v')
|
||||
path: join_path(base, 'src', 'auth_services.v')
|
||||
content: "module main
|
||||
|
||||
import crypto.hmac
|
||||
|
@ -269,7 +269,7 @@ fn auth_verify(token string) bool {
|
|||
"
|
||||
}
|
||||
c.files << ProjectFiles{
|
||||
path: join_path(base, 'src', 'index.html')
|
||||
path: join_path(base, 'src', 'index.html')
|
||||
content: "<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
|
@ -348,7 +348,7 @@ fn auth_verify(token string) bool {
|
|||
"
|
||||
}
|
||||
c.files << ProjectFiles{
|
||||
path: join_path(base, 'src', 'main.v')
|
||||
path: join_path(base, 'src', 'main.v')
|
||||
content: "module main
|
||||
|
||||
import vweb
|
||||
|
@ -391,7 +391,7 @@ pub fn (mut app App) index() vweb.Result {
|
|||
"
|
||||
}
|
||||
c.files << ProjectFiles{
|
||||
path: join_path(base, 'src', 'product_controller.v')
|
||||
path: join_path(base, 'src', 'product_controller.v')
|
||||
content: "module main
|
||||
|
||||
import vweb
|
||||
|
@ -457,7 +457,7 @@ pub fn (mut app App) controller_create_product(product_name string) vweb.Result
|
|||
"
|
||||
}
|
||||
c.files << ProjectFiles{
|
||||
path: join_path(base, 'src', 'product_entities.v')
|
||||
path: join_path(base, 'src', 'product_entities.v')
|
||||
content: "module main
|
||||
|
||||
@[table: 'products']
|
||||
|
@ -470,7 +470,7 @@ struct Product {
|
|||
"
|
||||
}
|
||||
c.files << ProjectFiles{
|
||||
path: join_path(base, 'src', 'product_service.v')
|
||||
path: join_path(base, 'src', 'product_service.v')
|
||||
content: "module main
|
||||
|
||||
import databases
|
||||
|
@ -517,7 +517,7 @@ fn (mut app App) service_get_all_products_from(user_id int) ![]Product {
|
|||
"
|
||||
}
|
||||
c.files << ProjectFiles{
|
||||
path: join_path(base, 'src', 'product_view_api.v')
|
||||
path: join_path(base, 'src', 'product_view_api.v')
|
||||
content: "module main
|
||||
|
||||
import json
|
||||
|
@ -556,7 +556,7 @@ pub fn get_product(token string) ![]User {
|
|||
"
|
||||
}
|
||||
c.files << ProjectFiles{
|
||||
path: join_path(base, 'src', 'product_view.v')
|
||||
path: join_path(base, 'src', 'product_view.v')
|
||||
content: "module main
|
||||
|
||||
import vweb
|
||||
|
@ -578,7 +578,7 @@ pub fn (mut app App) products() !vweb.Result {
|
|||
"
|
||||
}
|
||||
c.files << ProjectFiles{
|
||||
path: join_path(base, 'src', 'user_controllers.v')
|
||||
path: join_path(base, 'src', 'user_controllers.v')
|
||||
content: "module main
|
||||
|
||||
import vweb
|
||||
|
@ -648,7 +648,7 @@ pub fn (mut app App) controller_create_user(username string, password string) vw
|
|||
"
|
||||
}
|
||||
c.files << ProjectFiles{
|
||||
path: join_path(base, 'src', 'user_entities.v')
|
||||
path: join_path(base, 'src', 'user_entities.v')
|
||||
content: "module main
|
||||
|
||||
@[table: 'users']
|
||||
|
@ -663,7 +663,7 @@ mut:
|
|||
"
|
||||
}
|
||||
c.files << ProjectFiles{
|
||||
path: join_path(base, 'src', 'user_services.v')
|
||||
path: join_path(base, 'src', 'user_services.v')
|
||||
content: "module main
|
||||
|
||||
import crypto.bcrypt
|
||||
|
@ -732,7 +732,7 @@ fn (mut app App) service_get_user(id int) !User {
|
|||
"
|
||||
}
|
||||
c.files << ProjectFiles{
|
||||
path: join_path(base, 'src', 'user_view_api.v')
|
||||
path: join_path(base, 'src', 'user_view_api.v')
|
||||
content: "module main
|
||||
|
||||
import json
|
||||
|
|
|
@ -34,35 +34,35 @@ enum Template {
|
|||
fn main() {
|
||||
flags := [
|
||||
Flag{
|
||||
flag: .bool
|
||||
name: 'bin'
|
||||
flag: .bool
|
||||
name: 'bin'
|
||||
description: 'Use the template for an executable application [default].'
|
||||
},
|
||||
Flag{
|
||||
flag: .bool
|
||||
name: 'lib'
|
||||
flag: .bool
|
||||
name: 'lib'
|
||||
description: 'Use the template for a library project.'
|
||||
},
|
||||
Flag{
|
||||
flag: .bool
|
||||
name: 'web'
|
||||
flag: .bool
|
||||
name: 'web'
|
||||
description: 'Use the template for a vweb project.'
|
||||
},
|
||||
]
|
||||
mut cmd := Command{
|
||||
flags: [
|
||||
Flag{
|
||||
flag: .bool
|
||||
name: 'help'
|
||||
flag: .bool
|
||||
name: 'help'
|
||||
description: 'Print help information.'
|
||||
global: true
|
||||
global: true
|
||||
},
|
||||
]
|
||||
posix_mode: true
|
||||
commands: [
|
||||
commands: [
|
||||
Command{
|
||||
name: 'new'
|
||||
usage: '<project_name>'
|
||||
name: 'new'
|
||||
usage: '<project_name>'
|
||||
description: [
|
||||
'Creates a new V project in a directory with the specified project name.',
|
||||
'',
|
||||
|
@ -73,13 +73,13 @@ fn main() {
|
|||
parent: &Command{
|
||||
name: 'v'
|
||||
}
|
||||
posix_mode: true
|
||||
flags: flags
|
||||
posix_mode: true
|
||||
flags: flags
|
||||
pre_execute: validate
|
||||
execute: new_project
|
||||
execute: new_project
|
||||
},
|
||||
Command{
|
||||
name: 'init'
|
||||
name: 'init'
|
||||
description: [
|
||||
'Sets up a V project within the current directory.',
|
||||
'',
|
||||
|
@ -90,10 +90,10 @@ fn main() {
|
|||
parent: &Command{
|
||||
name: 'v'
|
||||
}
|
||||
posix_mode: true
|
||||
flags: flags
|
||||
posix_mode: true
|
||||
flags: flags
|
||||
pre_execute: validate
|
||||
execute: init_project
|
||||
execute: init_project
|
||||
},
|
||||
]
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ fn validate(cmd Command) ! {
|
|||
fn new_project(cmd Command) ! {
|
||||
mut c := Create{
|
||||
template: get_template(cmd)
|
||||
new_dir: true
|
||||
new_dir: true
|
||||
}
|
||||
c.prompt(cmd.args)
|
||||
println('Initialising ...')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue