This commit is contained in:
Daniel Gavin
2021-04-22 00:08:03 +02:00
parent b18e8898d8
commit 9b8563dfc0
2 changed files with 0 additions and 8 deletions

View File

@@ -146,13 +146,11 @@ reflect_args_structure :: proc(ctx: ^Flag_Context, v: any) -> Flag_Error {
tags := reflect.struct_field_tags(v.id);
for name, i in names {
flag: Flag;
type := types[i];
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 {
flag.optional = true;
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
for k, v in ctx.seen_flags {
if v.optional && v.parsed {
tag_value: i32 = 1;
mem.copy(v.tag_ptr, &tag_value, 4); //4 constant is probably not portable, but it works for me currently

View File

@@ -68,9 +68,7 @@ main :: proc() {
tick_time := time.tick_now();
if os.is_file(path) {
if _, ok := args.write.(bool); ok {
backup_path := strings.concatenate({path, "_bk"}, context.temp_allocator);
if data, ok := format_file(path); ok {
@@ -84,17 +82,14 @@ main :: proc() {
fmt.eprintf("failed to write %v", path);
}
} else {
if data, ok := format_file(path); ok {
fmt.println(transmute(string)data);
}
}
} else if os.is_dir(path) {
filepath.walk(path, walk_files);
for file in files {
fmt.println(file);
backup_path := strings.concatenate({file, "_bk"}, context.temp_allocator);