Reverting back to codegansta/cli

master
Frederick F. Kautz IV 10 years ago
parent 57d764778d
commit 7b0942980b
  1. 73
      main.go

@ -2,22 +2,49 @@ package main
import ( import (
"log" "log"
"os"
"github.com/codegangsta/cli"
"github.com/minio-io/minio/pkg/server" "github.com/minio-io/minio/pkg/server"
"github.com/spf13/cobra"
) )
func main() { func main() {
var tls bool app := cli.NewApp()
var storageTypeStr string app.Name = "minio"
var address string app.Usage = ""
var certFile string app.Flags = []cli.Flag{
var keyFile string cli.StringFlag{
var minioCommand = &cobra.Command{ Name: "http-address,a",
Use: "minio", Value: ":8080",
Short: "minio is a minimal object storage system", Usage: "http address to listen on",
Long: "", },
Run: func(cmd *cobra.Command, args []string) { cli.StringFlag{
Name: "cert,c",
Value: "",
Usage: "cert.pem",
},
cli.StringFlag{
Name: "key,k",
Value: "",
Usage: "key.pem",
},
cli.BoolFlag{
Name: "tls,t",
Usage: "http address to listen on",
},
cli.StringFlag{
Name: "storage-type,s",
Value: "file",
Usage: "valid entries: file,inmemory",
},
}
app.Action = func(c *cli.Context) {
tls := c.Bool("tls")
storageTypeStr := c.String("storage-type")
address := c.String("http-address")
log.Println(address)
certFile := c.String("cert")
keyFile := c.String("key")
storageType := getStorageType(storageTypeStr) storageType := getStorageType(storageTypeStr)
serverConfig := server.ServerConfig{ serverConfig := server.ServerConfig{
Address: address, Address: address,
@ -27,14 +54,24 @@ func main() {
StorageType: storageType, StorageType: storageType,
} }
server.Start(serverConfig) server.Start(serverConfig)
},
} }
minioCommand.PersistentFlags().BoolVarP(&tls, "tls", "t", false, "enable tls") app.Run(os.Args)
minioCommand.PersistentFlags().StringVarP(&storageTypeStr, "storage-type", "s", "file", "file,inmemory")
minioCommand.PersistentFlags().StringVarP(&address, "http-address", "a", ":8080", "http address") // var minioCommand = &cobra.Command{
minioCommand.PersistentFlags().StringVarP(&certFile, "cert", "c", "", "cert file path") // Use: "minio",
minioCommand.PersistentFlags().StringVarP(&keyFile, "key", "k", "", "key file path") // Short: "minio is a minimal object storage system",
minioCommand.Execute() // Long: "",
// Run: func(cmd *cobra.Command, args []string) {
// storageType := getStorageType(storageTypeStr)
// server.Start(serverConfig)
// },
// }
// minioCommand.PersistentFlags().BoolVarP(&tls, "tls", "t", false, "enable tls")
// minioCommand.PersistentFlags().StringVarP(&storageTypeStr, "storage-type", "s", "file", "file,inmemory")
// minioCommand.PersistentFlags().StringVarP(&address, "http-address", "a", ":8080", "http address")
// minioCommand.PersistentFlags().StringVarP(&certFile, "cert", "c", "", "cert file path")
// minioCommand.PersistentFlags().StringVarP(&keyFile, "key", "k", "", "key file path")
// minioCommand.Execute()
} }
func getStorageType(input string) server.StorageType { func getStorageType(input string) server.StorageType {

Loading…
Cancel
Save