drop redundant NArg check when looping Args
This commit is contained in:
		| @@ -28,29 +28,26 @@ import ( | |||||||
| func main() { | func main() { | ||||||
| 	indent := flag.Int("indent", 2, "default indent") | 	indent := flag.Int("indent", 2, "default indent") | ||||||
| 	flag.Parse() | 	flag.Parse() | ||||||
|  | 	for _, path := range flag.Args() { | ||||||
| 	if flag.NArg() > 0 { | 		sourceYaml, err := os.ReadFile(path) | ||||||
| 		for _, path := range flag.Args() { | 		if err != nil { | ||||||
| 			sourceYaml, err := os.ReadFile(path) | 			fmt.Fprintf(os.Stderr, "%s: %v\n", path, err) | ||||||
| 			if err != nil { | 			continue | ||||||
| 				fmt.Fprintf(os.Stderr, "%s: %v\n", path, err) | 		} | ||||||
| 				continue | 		rootNode, err := fetchYaml(sourceYaml) | ||||||
| 			} | 		if err != nil { | ||||||
| 			rootNode, err := fetchYaml(sourceYaml) | 			fmt.Fprintf(os.Stderr, "%s: %v\n", path, err) | ||||||
| 			if err != nil { | 			continue | ||||||
| 				fmt.Fprintf(os.Stderr, "%s: %v\n", path, err) | 		} | ||||||
| 				continue | 		writer, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0666) | ||||||
| 			} | 		if err != nil { | ||||||
| 			writer, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0666) | 			fmt.Fprintf(os.Stderr, "%s: %v\n", path, err) | ||||||
| 			if err != nil { | 			continue | ||||||
| 				fmt.Fprintf(os.Stderr, "%s: %v\n", path, err) | 		} | ||||||
| 				continue | 		err = streamYaml(writer, indent, rootNode) | ||||||
| 			} | 		if err != nil { | ||||||
| 			err = streamYaml(writer, indent, rootNode) | 			fmt.Fprintf(os.Stderr, "%s: %v\n", path, err) | ||||||
| 			if err != nil { | 			continue | ||||||
| 				fmt.Fprintf(os.Stderr, "%s: %v\n", path, err) |  | ||||||
| 				continue |  | ||||||
| 			} |  | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Benjamin Elder
					Benjamin Elder