fmt: fix alignment of struct init fields (#22025)

This commit is contained in:
yuyi 2024-08-11 14:11:24 +08:00 committed by GitHub
parent 99da5726db
commit c51d30bf53
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
671 changed files with 18817 additions and 18787 deletions

View file

@ -16,15 +16,15 @@ import cli
fn main() {
mut app := cli.Command{
name: 'example-app'
name: 'example-app'
description: 'example-app'
execute: fn (cmd cli.Command) ! {
execute: fn (cmd cli.Command) ! {
println('hello app')
return
}
commands: [
cli.Command{
name: 'sub'
name: 'sub'
execute: fn (cmd cli.Command) ! {
println('hello subcommand')
return
@ -35,4 +35,4 @@ fn main() {
app.setup()
app.parse(os.args)
}
```
```

View file

@ -2,7 +2,7 @@ import cli
fn test_if_command_parses_empty_args() {
mut cmd := cli.Command{
name: 'command'
name: 'command'
execute: empty_func
}
cmd.parse(['command'])
@ -11,7 +11,7 @@ fn test_if_command_parses_empty_args() {
fn test_if_command_parses_args() {
mut cmd := cli.Command{
name: 'command'
name: 'command'
execute: empty_func
}
cmd.parse(['command', 'arg0', 'arg1'])
@ -23,7 +23,7 @@ fn test_if_subcommands_parse_args() {
name: 'command'
}
subcmd := cli.Command{
name: 'subcommand'
name: 'subcommand'
execute: if_subcommands_parse_args_func
}
cmd.add_command(subcmd)
@ -43,7 +43,7 @@ fn test_default_subcommands() {
assert cmd.commands.any(it.name == 'man')
cmd = cli.Command{
name: 'command'
name: 'command'
version: '1.0.0'
}
cmd.parse(['command'])
@ -57,7 +57,7 @@ fn flag_should_be_set(cmd cli.Command) ! {
fn test_if_flag_gets_set() {
mut cmd := cli.Command{
name: 'command'
name: 'command'
execute: flag_should_be_set
}
cmd.add_flag(cli.Flag{
@ -69,12 +69,12 @@ fn test_if_flag_gets_set() {
fn test_if_flag_gets_set_with_abbrev() {
mut cmd := cli.Command{
name: 'command'
name: 'command'
execute: flag_should_be_set
}
cmd.add_flag(cli.Flag{
flag: .string
name: 'flag'
flag: .string
name: 'flag'
abbrev: 'f'
})
cmd.parse(['command', '-f', 'value'])
@ -82,13 +82,13 @@ fn test_if_flag_gets_set_with_abbrev() {
fn test_if_flag_gets_set_with_long_arg() {
mut cmd := cli.Command{
name: 'command'
execute: flag_should_be_set
name: 'command'
execute: flag_should_be_set
posix_mode: true
}
cmd.add_flag(cli.Flag{
flag: .string
name: 'flag'
flag: .string
name: 'flag'
abbrev: 'f'
})
cmd.parse(['command', '--flag', 'value'])
@ -105,7 +105,7 @@ fn assert_flags(cmd cli.Command) ! {
fn test_if_multiple_flags_get_set() {
mut cmd := cli.Command{
name: 'command'
name: 'command'
execute: assert_flags
}
cmd.add_flag(cli.Flag{
@ -125,7 +125,7 @@ fn test_if_multiple_flags_get_set() {
fn test_if_required_flags_get_set() {
mut cmd := cli.Command{
name: 'command'
name: 'command'
execute: assert_flags
}
cmd.add_flag(cli.Flag{
@ -137,8 +137,8 @@ fn test_if_required_flags_get_set() {
name: 'flag-2'
})
cmd.add_flag(cli.Flag{
flag: .int
name: 'value'
flag: .int
name: 'value'
required: true
})
cmd.parse(['command', '-flag', 'value', '-value', '42', '-flag-2', 'value-2'])
@ -151,11 +151,11 @@ fn flag_is_set_in_subcommand(cmd cli.Command) ! {
fn test_if_flag_gets_set_in_subcommand() {
mut cmd := cli.Command{
name: 'command'
name: 'command'
execute: empty_func
}
mut subcmd := cli.Command{
name: 'subcommand'
name: 'subcommand'
execute: flag_is_set_in_subcommand
}
subcmd.add_flag(cli.Flag{
@ -168,16 +168,16 @@ fn test_if_flag_gets_set_in_subcommand() {
fn test_if_global_flag_gets_set_in_subcommand() {
mut cmd := cli.Command{
name: 'command'
name: 'command'
execute: empty_func
}
cmd.add_flag(cli.Flag{
flag: .string
name: 'flag'
flag: .string
name: 'flag'
global: true
})
subcmd := cli.Command{
name: 'subcommand'
name: 'subcommand'
execute: flag_is_set_in_subcommand
}
cmd.add_command(subcmd)
@ -186,10 +186,10 @@ fn test_if_global_flag_gets_set_in_subcommand() {
fn test_command_setup() {
mut cmd := cli.Command{
name: 'root'
name: 'root'
commands: [
cli.Command{
name: 'child'
name: 'child'
commands: [
cli.Command{
name: 'child-child'

View file

@ -113,8 +113,8 @@ fn test_if_float_flag_parses() {
fn test_if_flag_parses_with_abbrev() {
mut flag := cli.Flag{
flag: .bool
name: 'flag'
flag: .bool
name: 'flag'
abbrev: 'f'
}
mut value := false
@ -124,8 +124,8 @@ fn test_if_flag_parses_with_abbrev() {
value = false
flag = cli.Flag{
flag: .bool
name: 'flag'
flag: .bool
name: 'flag'
abbrev: 'f'
}
flag.parse(['-f'], true) or { panic(err) }
@ -150,8 +150,8 @@ fn test_if_multiple_value_on_single_value() {
fn test_default_value() {
mut flag := cli.Flag{
flag: .float
name: 'flag'
flag: .float
name: 'flag'
default_value: ['1.234']
}
@ -160,8 +160,8 @@ fn test_default_value() {
assert value == 3.14158
flag = cli.Flag{
flag: .float
name: 'flag'
flag: .float
name: 'flag'
default_value: ['1.234']
}

View file

@ -10,19 +10,19 @@ const spacing = 2
fn help_flag(with_abbrev bool) Flag {
sabbrev := if with_abbrev { 'h' } else { '' }
return Flag{
flag: .bool
name: 'help'
abbrev: sabbrev
flag: .bool
name: 'help'
abbrev: sabbrev
description: 'Prints help information.'
}
}
fn help_cmd() Command {
return Command{
name: 'help'
usage: '<command>'
name: 'help'
usage: '<command>'
description: 'Prints help information.'
execute: print_help_for_command
execute: print_help_for_command
}
}

View file

@ -2,34 +2,34 @@ module cli
fn test_help_message() {
mut cmd := Command{
name: 'command'
name: 'command'
description: 'description'
commands: [
commands: [
Command{
name: 'sub'
name: 'sub'
description: 'subcommand'
},
Command{
name: 'sub2'
name: 'sub2'
description: 'another subcommand'
},
]
flags: [
Flag{
flag: .string
name: 'str'
flag: .string
name: 'str'
description: 'str flag'
},
Flag{
flag: .bool
name: 'bool'
flag: .bool
name: 'bool'
description: 'bool flag'
abbrev: 'b'
abbrev: 'b'
},
Flag{
flag: .string
name: 'required'
abbrev: 'r'
flag: .string
name: 'required'
abbrev: 'r'
required: true
},
]

View file

@ -4,18 +4,18 @@ import time
fn man_flag() Flag {
return Flag{
flag: .bool
name: 'man'
flag: .bool
name: 'man'
description: 'Prints the auto-generated manpage.'
}
}
fn man_cmd() Command {
return Command{
name: 'man'
usage: '<subcommand>'
name: 'man'
usage: '<subcommand>'
description: 'Prints the auto-generated manpage.'
execute: print_manpage_for_command
execute: print_manpage_for_command
}
}

View file

@ -2,34 +2,34 @@ module cli
fn test_manpage() {
mut cmd := Command{
name: 'command'
name: 'command'
description: 'description'
commands: [
commands: [
Command{
name: 'sub'
name: 'sub'
description: 'subcommand'
},
Command{
name: 'sub2'
name: 'sub2'
description: 'another subcommand'
},
]
flags: [
Flag{
flag: .string
name: 'str'
flag: .string
name: 'str'
description: 'str flag'
},
Flag{
flag: .bool
name: 'bool'
flag: .bool
name: 'bool'
description: 'bool flag'
abbrev: 'b'
abbrev: 'b'
},
Flag{
flag: .string
name: 'required'
abbrev: 'r'
flag: .string
name: 'required'
abbrev: 'r'
required: true
},
]

View file

@ -3,18 +3,18 @@ module cli
fn version_flag(with_abbrev bool) Flag {
sabbrev := if with_abbrev { 'v' } else { '' }
return Flag{
flag: .bool
name: 'version'
abbrev: sabbrev
flag: .bool
name: 'version'
abbrev: sabbrev
description: 'Prints version information.'
}
}
fn version_cmd() Command {
return Command{
name: 'version'
name: 'version'
description: 'Prints version information.'
execute: print_version_for_command
execute: print_version_for_command
}
}