vitess.io/vitess@v0.16.2/go/cmd/vtctldclient/cli/cobra.go (about)

     1  /*
     2  Copyright 2021 The Vitess Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8  	http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package cli
    18  
    19  import "github.com/spf13/cobra"
    20  
    21  // FinishedParsing transitions a cobra.Command from treating RunE errors as
    22  // usage errors to treating them just as normal runtime errors that should be
    23  // propagated up to the root command's Execute method without also printing the
    24  // subcommand's usage text on stderr. A subcommand should call this function
    25  // from its RunE function when it has finished processing its flags and is
    26  // moving into the pure "business logic" of its entrypoint.
    27  //
    28  // Package vitess.io/vitess/go/cmd/vtctldclient/internal/command has more
    29  // details on why this exists.
    30  func FinishedParsing(cmd *cobra.Command) {
    31  	cmd.SilenceUsage = true
    32  }