fmt: fix and simplify align of struct fields (#21995)

This commit is contained in:
yuyi 2024-08-06 01:23:39 +08:00 committed by GitHub
parent 576a0abcc7
commit ddb6685d8a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
139 changed files with 553 additions and 519 deletions

View file

@ -42,9 +42,9 @@ import os
@[version: '1.2.3']
@[name: 'app']
struct Config {
show_version bool @[short: v; xdoc: 'Show version and exit']
debug_level int @[long: debug; short: d; xdoc: 'Debug level']
level f32 @[only: l; xdoc: 'This doc text is overwritten']
show_version bool @[short: v; xdoc: 'Show version and exit']
debug_level int @[long: debug; short: d; xdoc: 'Debug level']
level f32 @[only: l; xdoc: 'This doc text is overwritten']
example string
square bool
show_help bool @[long: help; short: h]

View file

@ -15,8 +15,8 @@ struct Config {
paths []string @[tail]
not_mapped string = 'not changed'
e bool
b bool @[long: Dev; only: d]
u string @[short: c]
b bool @[long: Dev; only: d]
u string @[short: c]
}
fn test_cmd_exe() {

View file

@ -1,8 +1,8 @@
module flag
struct FlagData {
raw string @[required]
field_name string @[required]
raw string @[required]
field_name string @[required]
delimiter string
name string
arg ?string
@ -28,7 +28,7 @@ pub enum Style {
}
struct StructInfo {
name string // name of the struct itself
name string // name of the struct itself
attrs map[string]string // collection of `@[x: y]` sat on the struct, read via reflection
fields map[string]StructField
}
@ -72,7 +72,7 @@ fn (sf StructField) shortest_match_name() ?string {
@[params]
pub struct ParseConfig {
pub:
delimiter string = '-' // delimiter used for flags
delimiter string = '-' // delimiter used for flags
style Style = .short_long // expected flag style
stop ?string // single, usually '--', string that stops parsing flags/options
skip u16 // skip this amount in the input argument array, usually `1` for skipping executable or subcmd entry
@ -81,7 +81,7 @@ pub:
@[params]
pub struct DocConfig {
pub:
delimiter string = '-' // delimiter used for flags
delimiter string = '-' // delimiter used for flags
style Style = .short_long // expected flag style
pub mut:
name string // application name

View file

@ -153,13 +153,13 @@ Footer content'
@[name: 'flag_to_doc_test']
@[version: '1.0']
struct DocTest {
show_version bool @[short: v; xdoc: 'Show version and exit']
debug_level int @[long: debug; short: d; xdoc: 'Debug level']
level f32 @[only: l; xdoc: 'Override this doc string']
show_version bool @[short: v; xdoc: 'Show version and exit']
debug_level int @[long: debug; short: d; xdoc: 'Debug level']
level f32 @[only: l; xdoc: 'Override this doc string']
example string
square bool
multi int @[only: m; repeats]
wroom []int @[short: w]
multi int @[only: m; repeats]
wroom []int @[short: w]
the_limit string
}

View file

@ -28,9 +28,9 @@ struct Config {
device []string @[short: d]
paths []string @[tail]
amount int = 1
verbosity int @[repeats; short: v]
show_version bool @[long: version]
no_long_beef bool @[only: n]
verbosity int @[repeats; short: v]
show_version bool @[long: version]
no_long_beef bool @[only: n]
}
struct LongConfig {
@ -39,7 +39,7 @@ struct LongConfig {
some_test string = 'abc' @[long: test]
path string @[tail]
amount int = 1
show_version bool @[long: version]
show_version bool @[long: version]
}
struct IgnoreConfig {

View file

@ -9,9 +9,9 @@ const exe_and_go_flag_args_with_tail = ['/path/to/exe', '-version', '--flag', '-
struct Prefs {
flag bool
flag_value string
version bool @[short: v]
is_live bool @[long: live]
is_done bool @[long: done]
version bool @[short: v]
is_live bool @[long: live]
is_done bool @[long: done]
test string
defines []string @[long: define; short: d]
tail []string @[tail]

View file

@ -21,8 +21,8 @@ struct Config {
verbosity int @[repeats; short: v]
not_mapped string = 'not changed'
x bool
b bool @[only: y]
u int @[short: z]
b bool @[only: y]
u int @[short: z]
}
fn test_pure_posix_short() {

View file

@ -7,9 +7,9 @@ const exe_and_v_args_with_tail = ['/path/to/exe', '-version', '-d', 'ident=val',
'-done', '-d', 'two', '-live', 'run', '/path/to']
struct Prefs {
version bool @[short: v]
is_live bool @[long: live]
is_done bool @[long: done]
version bool @[short: v]
is_live bool @[long: live]
is_done bool @[long: done]
test string
defines []string @[long: define; short: d]
tail []string @[tail]