github.com/SamarSidharth/kpt@v0.0.0-20231122062228-c7d747ae3ace/commands/alpha/alphacmd.go (about)

     1  // Copyright 2022 The kpt Authors
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //      http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package alpha
    16  
    17  import (
    18  	"context"
    19  
    20  	"github.com/GoogleContainerTools/kpt/commands/alpha/license"
    21  	"github.com/GoogleContainerTools/kpt/commands/alpha/live"
    22  	"github.com/GoogleContainerTools/kpt/commands/alpha/repo"
    23  	"github.com/GoogleContainerTools/kpt/commands/alpha/rollouts"
    24  	"github.com/GoogleContainerTools/kpt/commands/alpha/rpkg"
    25  	"github.com/GoogleContainerTools/kpt/commands/alpha/sync"
    26  	"github.com/GoogleContainerTools/kpt/commands/alpha/wasm"
    27  
    28  	"github.com/GoogleContainerTools/kpt/internal/docs/generated/alphadocs"
    29  	"github.com/GoogleContainerTools/kpt/internal/util/porch"
    30  	"github.com/spf13/cobra"
    31  )
    32  
    33  func GetCommand(ctx context.Context, _, version string) *cobra.Command {
    34  	alpha := &cobra.Command{
    35  		Use:   "alpha",
    36  		Short: alphadocs.AlphaShort,
    37  		Long:  alphadocs.AlphaLong,
    38  		RunE: func(cmd *cobra.Command, args []string) error {
    39  			h, err := cmd.Flags().GetBool("help")
    40  			if err != nil {
    41  				return err
    42  			}
    43  			if h {
    44  				return cmd.Help()
    45  			}
    46  			return cmd.Usage()
    47  		},
    48  		Hidden: porch.HidePorchCommands,
    49  	}
    50  
    51  	alpha.AddCommand(
    52  		repo.NewCommand(ctx, version),
    53  		rpkg.NewCommand(ctx, version),
    54  		sync.NewCommand(ctx, version),
    55  		wasm.NewCommand(ctx, version),
    56  		live.GetCommand(ctx, "", version),
    57  		license.NewCommand(ctx, version),
    58  		rollouts.NewCommand(ctx, version),
    59  	)
    60  
    61  	return alpha
    62  }