Skip to content

Commit 8a7c9a6

Browse files
committed
error on unmatched instance name while still printing info
Signed-off-by: Sahaj Bhakta <[email protected]>
1 parent e81632b commit 8a7c9a6

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

cmd/limactl/list.go

+12-2
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,15 @@ func listAction(cmd *cobra.Command, args []string) error {
124124
}
125125

126126
instanceNames := []string{}
127+
unmatchedInstances := false
127128
if len(args) > 0 {
128129
for _, arg := range args {
129130
matches := instanceMatches(arg, allinstances)
130131
if len(matches) > 0 {
131132
instanceNames = append(instanceNames, matches...)
132133
} else {
133-
return fmt.Errorf("no instance matching %v found", arg)
134+
logrus.Warnf("No instance matching %v found.", arg)
135+
unmatchedInstances = true
134136
}
135137
}
136138
} else {
@@ -141,6 +143,9 @@ func listAction(cmd *cobra.Command, args []string) error {
141143
for _, instName := range instanceNames {
142144
fmt.Fprintln(cmd.OutOrStdout(), instName)
143145
}
146+
if unmatchedInstances {
147+
os.Exit(1)
148+
}
144149
return nil
145150
}
146151

@@ -174,7 +179,12 @@ func listAction(cmd *cobra.Command, args []string) error {
174179
}
175180
}
176181
}
177-
return store.PrintInstances(out, instances, format, &options)
182+
183+
err = store.PrintInstances(out, instances, format, &options)
184+
if err == nil && unmatchedInstances {
185+
os.Exit(1)
186+
}
187+
return err
178188
}
179189

180190
func listBashComplete(cmd *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) {

0 commit comments

Comments
 (0)