Skip to content

Commit

Permalink
feat: set up barebones CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
soedirgo committed Jun 15, 2021
1 parent dc6e969 commit 51c9d38
Show file tree
Hide file tree
Showing 5 changed files with 1,089 additions and 0 deletions.
62 changes: 62 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package cmd

import (
// "fmt"
// "os"

// homedir "github.com/mitchellh/go-homedir"
"github.com/spf13/cobra"
// "github.com/spf13/viper"
)

// var cfgFile string

// rootCmd represents the base command when called without any subcommands
var rootCmd = &cobra.Command{
Use: "supabase",
Short: "TODO",
Long: `TODO`,
}

// Execute adds all child commands to the root command and sets flags appropriately.
// This is called by main.main(). It only needs to happen once to the rootCmd.
func Execute() {
cobra.CheckErr(rootCmd.Execute())
}

func init() {
// cobra.OnInitialize(initConfig)

// Here you will define your flags and configuration settings.
// Cobra supports persistent flags, which, if defined here,
// will be global for your application.

// rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.cli.yaml)")

// Cobra also supports local flags, which will only run
// when this action is called directly.
// rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
}

// initConfig reads in config file and ENV variables if set.
// func initConfig() {
// if cfgFile != "" {
// // Use config file from the flag.
// viper.SetConfigFile(cfgFile)
// } else {
// // Find home directory.
// home, err := homedir.Dir()
// cobra.CheckErr(err)
//
// // Search config in home directory with name ".cli" (without extension).
// viper.AddConfigPath(home)
// viper.SetConfigName(".cli")
// }
//
// viper.AutomaticEnv() // read in environment variables that match
//
// // If a config file is found, read it in.
// if err := viper.ReadInConfig(); err == nil {
// fmt.Fprintln(os.Stderr, "Using config file:", viper.ConfigFileUsed())
// }
// }
33 changes: 33 additions & 0 deletions cmd/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package cmd

import (
"fmt"

"github.com/spf13/cobra"
)

// Passed from `-ldflags`. See https://stackoverflow.com/questions/11354518/application-auto-build-versioning.
var version string

var versionCmd = &cobra.Command{
Use: "version",
Short: "TODO",
Long: `TODO`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println(version)
},
}

func init() {
rootCmd.AddCommand(versionCmd)

// Here you will define your flags and configuration settings.

// Cobra supports Persistent Flags which will work for this command
// and all subcommands, e.g.:
// versionCmd.PersistentFlags().String("foo", "", "A help for foo")

// Cobra supports local flags which will only run when this command
// is called directly, e.g.:
// versionCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
}
11 changes: 11 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module github.com/supabase/cli

go 1.16

require (
github.com/containerd/containerd v1.5.2 // indirect
github.com/docker/docker v20.10.7+incompatible
github.com/docker/go-connections v0.4.0 // indirect
github.com/morikuni/aec v1.0.0 // indirect
github.com/spf13/cobra v1.1.3
)

0 comments on commit 51c9d38

Please sign in to comment.