Skip to content
This repository was archived by the owner on Sep 15, 2024. It is now read-only.

Commit 7a13e15

Browse files
committed
Fix functionality for prefixing output
1 parent f1c7f7d commit 7a13e15

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

cmd/root.go

+9-2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ var (
2424
}
2525

2626
maxResults := viper.GetInt("max-results")
27+
showQuery := viper.GetBool("show-query")
2728

2829
for _, q := range queries {
2930
n := nominatim.Nominatim{}
@@ -41,7 +42,13 @@ var (
4142
}
4243

4344
for _, result := range results {
44-
fmt.Printf("%s | (%s, %s)\n", q, result.LatStr, result.LngStr)
45+
line := ""
46+
if showQuery {
47+
line += fmt.Sprintf("%s | ", q)
48+
}
49+
50+
line += fmt.Sprintf("(%s, %s)", result.LatStr, result.LngStr)
51+
fmt.Println(line)
4552
}
4653
}
4754

@@ -59,7 +66,7 @@ func init() {
5966
rootCmd.PersistentFlags().IntP("max-results", "n", 0, "Maximum number of results to return")
6067
viper.BindPFlag("max-results", rootCmd.PersistentFlags().Lookup("max-results"))
6168

62-
rootCmd.PersistentFlags().IntP("show-query", "s", 0, "Prefix results with query")
69+
rootCmd.PersistentFlags().BoolP("show-query", "s", false, "Prefix results with query")
6370
viper.BindPFlag("show-query", rootCmd.PersistentFlags().Lookup("show-query"))
6471
}
6572

0 commit comments

Comments
 (0)