mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +00:00
style
This commit is contained in:
@@ -146,13 +146,11 @@ reflect_args_structure :: proc(ctx: ^Flag_Context, v: any) -> Flag_Error {
|
|||||||
tags := reflect.struct_field_tags(v.id);
|
tags := reflect.struct_field_tags(v.id);
|
||||||
|
|
||||||
for name, i in names {
|
for name, i in names {
|
||||||
|
|
||||||
flag: Flag;
|
flag: Flag;
|
||||||
|
|
||||||
type := types[i];
|
type := types[i];
|
||||||
|
|
||||||
if named_type, ok := type.variant.(Type_Info_Named); ok {
|
if named_type, ok := type.variant.(Type_Info_Named); ok {
|
||||||
|
|
||||||
if union_type, ok := named_type.base.variant.(Type_Info_Union); ok && union_type.maybe && len(union_type.variants) == 1 {
|
if union_type, ok := named_type.base.variant.(Type_Info_Union); ok && union_type.maybe && len(union_type.variants) == 1 {
|
||||||
flag.optional = true;
|
flag.optional = true;
|
||||||
flag.tag_ptr = rawptr(uintptr(union_type.tag_offset) + uintptr(v.data) + uintptr(offsets[i]));
|
flag.tag_ptr = rawptr(uintptr(union_type.tag_offset) + uintptr(v.data) + uintptr(offsets[i]));
|
||||||
@@ -202,7 +200,6 @@ parse :: proc(v: any, args: []string) -> Flag_Error {
|
|||||||
|
|
||||||
//validate that the required flags were actually set
|
//validate that the required flags were actually set
|
||||||
for k, v in ctx.seen_flags {
|
for k, v in ctx.seen_flags {
|
||||||
|
|
||||||
if v.optional && v.parsed {
|
if v.optional && v.parsed {
|
||||||
tag_value: i32 = 1;
|
tag_value: i32 = 1;
|
||||||
mem.copy(v.tag_ptr, &tag_value, 4); //4 constant is probably not portable, but it works for me currently
|
mem.copy(v.tag_ptr, &tag_value, 4); //4 constant is probably not portable, but it works for me currently
|
||||||
|
|||||||
@@ -68,9 +68,7 @@ main :: proc() {
|
|||||||
tick_time := time.tick_now();
|
tick_time := time.tick_now();
|
||||||
|
|
||||||
if os.is_file(path) {
|
if os.is_file(path) {
|
||||||
|
|
||||||
if _, ok := args.write.(bool); ok {
|
if _, ok := args.write.(bool); ok {
|
||||||
|
|
||||||
backup_path := strings.concatenate({path, "_bk"}, context.temp_allocator);
|
backup_path := strings.concatenate({path, "_bk"}, context.temp_allocator);
|
||||||
|
|
||||||
if data, ok := format_file(path); ok {
|
if data, ok := format_file(path); ok {
|
||||||
@@ -84,17 +82,14 @@ main :: proc() {
|
|||||||
fmt.eprintf("failed to write %v", path);
|
fmt.eprintf("failed to write %v", path);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if data, ok := format_file(path); ok {
|
if data, ok := format_file(path); ok {
|
||||||
fmt.println(transmute(string)data);
|
fmt.println(transmute(string)data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if os.is_dir(path) {
|
} else if os.is_dir(path) {
|
||||||
|
|
||||||
filepath.walk(path, walk_files);
|
filepath.walk(path, walk_files);
|
||||||
|
|
||||||
for file in files {
|
for file in files {
|
||||||
|
|
||||||
fmt.println(file);
|
fmt.println(file);
|
||||||
|
|
||||||
backup_path := strings.concatenate({file, "_bk"}, context.temp_allocator);
|
backup_path := strings.concatenate({file, "_bk"}, context.temp_allocator);
|
||||||
|
|||||||
Reference in New Issue
Block a user