Add runtime language cli argument option

This commit is contained in:
Tobie Morgan Hitchcock 2016-09-06 11:19:29 +01:00
parent 8758ce19ff
commit fecc1c94b8
3 changed files with 23 additions and 0 deletions

View file

@ -20,6 +20,7 @@ import (
"regexp"
"strings"
"github.com/abcum/surreal/cnf"
"github.com/abcum/surreal/log"
"github.com/abcum/surreal/util/uuid"
)
@ -104,6 +105,21 @@ func setup() {
log.Fatal("Specify a valid PEM encoded private key file.")
}
// --------------------------------------------------
// Lang
// --------------------------------------------------
// Ensure that the default
// language options are set
if opts.DB.Lang == "" {
opts.DB.Lang = "lua"
}
if opts.DB.Lang != "js" && opts.DB.Lang != "lua" {
log.Fatal("Specify a valid runtime language. Valid languages are js, or lua.")
}
// --------------------------------------------------
// Auth
// --------------------------------------------------
@ -287,4 +303,6 @@ func setup() {
}
cnf.Settings = opts
}

View file

@ -79,6 +79,8 @@ func init() {
startCmd.PersistentFlags().StringVar(&opts.DB.Cert.Key, "db-key", "", "Path to the private key file used to connect to the remote database.")
startCmd.PersistentFlags().StringVar(&opts.DB.Path, "db-path", "", flag("db"))
startCmd.PersistentFlags().StringVarP(&opts.DB.Lang, "language", "l", "lua", "The runtime language to use.")
startCmd.PersistentFlags().StringVarP(&opts.Cluster.Join, "join", "j", "", flag("join"))
startCmd.PersistentFlags().StringVarP(&opts.DB.Code, "key", "k", "", flag("key"))

View file

@ -14,6 +14,8 @@
package cnf
var Settings *Options
// Options defines global configuration options
type Options struct {
DB struct {
@ -23,6 +25,7 @@ type Options struct {
Host string // Surreal host to connect to
Port string // Surreal port to connect to
Base string // Base key to use in KV stores
Lang string // Base key to use in KV stores
Cert struct {
CA string
Crt string