github.com/actions-on-google/gactions@v3.2.0+incompatible/cmd/gactions/cli/logout/logout.go (about)

     1  // Copyright 2020 Google LLC
     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  //     https://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 logout provides an implementation of "gactions login" command.
    16  package logout
    17  
    18  import (
    19  	"github.com/actions-on-google/gactions/api/apiutils"
    20  	"github.com/actions-on-google/gactions/log"
    21  	"github.com/actions-on-google/gactions/project"
    22  	"github.com/spf13/cobra"
    23  )
    24  
    25  // AddCommand adds the push sub-command to the passed in root command.
    26  func AddCommand(root *cobra.Command, proj project.Project) {
    27  	logout := &cobra.Command{
    28  		Use:   "logout",
    29  		Short: "Log gactions CLI out of your Google Account.",
    30  		Long:  "Log gactions CLI out of your Google Account.",
    31  		RunE: func(cmd *cobra.Command, args []string) error {
    32  			if err := apiutils.RemoveToken(); err != nil {
    33  				return err
    34  			}
    35  			log.DoneMsgln("Successfully logged out.")
    36  			return nil
    37  		},
    38  		Args: cobra.NoArgs,
    39  	}
    40  	root.AddCommand(logout)
    41  }