File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -22,6 +22,10 @@ var rootCmd = &cobra.Command{
2222 Short : "perform actions on firestore" ,
2323 SilenceUsage : true ,
2424 PersistentPreRunE : func (cmd * cobra.Command , args []string ) error {
25+ if isCompletionCommand (cmd ) {
26+ return nil
27+ }
28+
2529 if projectId == "" {
2630 envValue := os .Getenv ("PROJECT_ID" )
2731 if envValue == "" {
@@ -48,6 +52,16 @@ var rootCmd = &cobra.Command{
4852 },
4953}
5054
55+ func isCompletionCommand (cmd * cobra.Command ) bool {
56+ for cmd != nil {
57+ if cmd .Name () == "completion" || cmd .Name () == cobra .ShellCompRequestCmd {
58+ return true
59+ }
60+ cmd = cmd .Parent ()
61+ }
62+ return false
63+ }
64+
5165// Execute adds all child commands to the root command and sets flags appropriately.
5266// This is called by main.main(). It only needs to happen once to the rootCmd.
5367func Execute () {
You can’t perform that action at this time.
0 commit comments