From fecc1c94b80e093f691b5d93e189f00aeba89a99 Mon Sep 17 00:00:00 2001 From: Tobie Morgan Hitchcock Date: Tue, 6 Sep 2016 11:19:29 +0100 Subject: [PATCH] Add runtime language cli argument option --- cli/setup.go | 18 ++++++++++++++++++ cli/start.go | 2 ++ cnf/cnf.go | 3 +++ 3 files changed, 23 insertions(+) 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