1- // Copyright © 2018 NAME HERE <EMAIL ADDRESS>
1+ // Copyright © 2018 Codefresh.Inc
22//
33// Licensed under the Apache License, Version 2.0 (the "License");
44// you may not use this file except in compliance with the License.
@@ -18,29 +18,19 @@ import (
1818 "fmt"
1919
2020 "github.com/codefresh-io/go-sdk/internal"
21- "github.com/codefresh-io/go-sdk/pkg/codefresh "
21+ "github.com/codefresh-io/go-sdk/pkg/utils "
2222 humanize "github.com/dustin/go-humanize"
2323 "github.com/spf13/cobra"
2424 "github.com/spf13/viper"
2525)
2626
27- // getTokensCmd represents the getTokens command
2827var getTokensCmd = & cobra.Command {
2928 Use : "tokens" ,
3029 Aliases : []string {"token" },
31- Short : "A brief description of your command" ,
32- Long : `A longer description that spans multiple lines and likely contains examples
33- and usage of using your command. For example:
34-
35- Cobra is a CLI library for Go that empowers applications.
36- This application is a tool to generate the needed files
37- to quickly create a Cobra application.` ,
30+ Short : "Get tokens" ,
3831 Run : func (cmd * cobra.Command , args []string ) {
3932 client := viper .Get ("codefresh" )
40- codefreshClient , ok := client .(codefresh.Codefresh )
41- if ! ok {
42- panic ("Faild to create Codefresh cleint" )
43- }
33+ codefreshClient := utils .CastToCodefreshOrDie (client )
4434 table := internal .CreateTable ()
4535 table .SetHeader ([]string {"Created" , "ID" , "Name" , "Reference Subject" , "Reference Type" , "Token" })
4636 table .Append ([]string {"" , "" , "" })
@@ -61,14 +51,4 @@ to quickly create a Cobra application.`,
6151
6252func init () {
6353 getCmd .AddCommand (getTokensCmd )
64-
65- // Here you will define your flags and configuration settings.
66-
67- // Cobra supports Persistent Flags which will work for this command
68- // and all subcommands, e.g.:
69- // getTokensCmd.PersistentFlags().String("foo", "", "A help for foo")
70-
71- // Cobra supports local flags which will only run when this command
72- // is called directly, e.g.:
73- // getTokensCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
7454}
0 commit comments