Skip to content

Instantly share code, notes, and snippets.

@sdomino
Last active January 24, 2017 22:47
Show Gist options
  • Save sdomino/d2639a4270adde117cb9641d32270632 to your computer and use it in GitHub Desktop.
Save sdomino/d2639a4270adde117cb9641d32270632 to your computer and use it in GitHub Desktop.
package commands
import (
"fmt"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
var (
// alias for show
fetchCmd = &cobra.Command{
Hidden: true,
Use: "fetch",
Short: "Display a file from the hoarder storage",
Long: ``,
Run: show,
}
// alias for show
getCmd = &cobra.Command{
Hidden: true,
Use: "get",
Short: "Display a file from the hoarder storage",
Long: ``,
Run: show,
}
//
showCmd = &cobra.Command{
Use: "show",
Short: "Display a file from the hoarder storage",
Long: ``,
Run: show,
}
)
// init
func init() {
fetchCmd.Flags().StringVarP(&key, "key", "k", "", "The key to get the data by")
getCmd.Flags().StringVarP(&key, "key", "k", "", "The key to get the data by")
showCmd.Flags().StringVarP(&key, "key", "k", "", "The key to get the data by")
}
// show utilizes the api to show data associated to key
func show(ccmd *cobra.Command, args []string) {
// handle any missing args
switch {
case key == "":
fmt.Println("Missing key - please provide the key for the record you'd like to create")
return
}
// do command stuff...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment