diff --git a/cli/setup.go b/cli/setup.go index 6fc0cbb3..5a7c5a61 100644 --- a/cli/setup.go +++ b/cli/setup.go @@ -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 + } diff --git a/cli/start.go b/cli/start.go index f931d5e3..7ea29e6f 100644 --- a/cli/start.go +++ b/cli/start.go @@ -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")) diff --git a/cnf/cnf.go b/cnf/cnf.go index a81863e9..4823092c 100644 --- a/cnf/cnf.go +++ b/cnf/cnf.go @@ -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