Merge pull request #90 from fkautz/pr_out_reverting_back_to_codegansta_cli

master
Frederick F. Kautz IV 10 years ago
commit 391468c80e
  1. 89
      main.go

@ -2,39 +2,76 @@ 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{
storageType := getStorageType(storageTypeStr) Name: "cert,c",
serverConfig := server.ServerConfig{ Value: "",
Address: address, Usage: "cert.pem",
Tls: tls, },
CertFile: certFile, cli.StringFlag{
KeyFile: keyFile, Name: "key,k",
StorageType: storageType, Value: "",
} Usage: "key.pem",
server.Start(serverConfig) },
cli.BoolFlag{
Name: "tls,t",
Usage: "http address to listen on",
},
cli.StringFlag{
Name: "storage-type,s",
Value: "file",
Usage: "valid entries: file,inmemory",
}, },
} }
minioCommand.PersistentFlags().BoolVarP(&tls, "tls", "t", false, "enable tls") app.Action = func(c *cli.Context) {
minioCommand.PersistentFlags().StringVarP(&storageTypeStr, "storage-type", "s", "file", "file,inmemory") tls := c.Bool("tls")
minioCommand.PersistentFlags().StringVarP(&address, "http-address", "a", ":8080", "http address") storageTypeStr := c.String("storage-type")
minioCommand.PersistentFlags().StringVarP(&certFile, "cert", "c", "", "cert file path") address := c.String("http-address")
minioCommand.PersistentFlags().StringVarP(&keyFile, "key", "k", "", "key file path") log.Println(address)
minioCommand.Execute() certFile := c.String("cert")
keyFile := c.String("key")
storageType := getStorageType(storageTypeStr)
serverConfig := server.ServerConfig{
Address: address,
Tls: tls,
CertFile: certFile,
KeyFile: keyFile,
StorageType: storageType,
}
server.Start(serverConfig)
}
app.Run(os.Args)
// var minioCommand = &cobra.Command{
// Use: "minio",
// Short: "minio is a minimal object storage system",
// 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