diff options
author | Christian Pointner <equinox@helsinki.at> | 2015-12-18 20:36:58 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2015-12-18 20:36:58 (GMT) |
commit | e9da89ac2fd71a172a235034b5541ce8db917fac (patch) | |
tree | 021efca03fccbc8b0eb4f0ba79d5792d6fe8f1cb | |
parent | 6e5d2a18a5d1794433e72a8f1b7df899d2c4ffe0 (diff) |
implemened set command for telnet control interface
-rw-r--r-- | src/helsinki.at/rhimportd/ctrlTelnet.go | 79 |
1 files changed, 75 insertions, 4 deletions
diff --git a/src/helsinki.at/rhimportd/ctrlTelnet.go b/src/helsinki.at/rhimportd/ctrlTelnet.go index dd95cd6..38ee5c0 100644 --- a/src/helsinki.at/rhimportd/ctrlTelnet.go +++ b/src/helsinki.at/rhimportd/ctrlTelnet.go @@ -29,6 +29,7 @@ import ( "fmt" "helsinki.at/rhimport" "net" + "strconv" "strings" ) @@ -87,6 +88,8 @@ func (c *TelnetClient) handle_cmd_help(args []string) { c.say(" AutotrimLevel int autotrim level in dB (defaults to: %v)", c.conf.ImportParamDefaults.AutotrimLevel) c.say(" UseMetaData bool extract meta data from source file (defaults to: %v)", c.conf.ImportParamDefaults.UseMetaData) c.say("") + c.say(" UserName, Password and SourceUri are mandatory parameters.") + c.say("") c.say(" If ShowId is supplied GroupName, Channels, NomalizationLevel, AutorimLevel, UseMetaData") c.say(" and Cut will be ignored. The values from the shows dropbox will be used instead. Cart may") c.say(" be specified but must point to a empty cart within that show. If Cart is 0 the next free") @@ -128,10 +131,78 @@ func (c *TelnetClient) handle_cmd_help(args []string) { } func (c *TelnetClient) handle_cmd_set(args []string) { - c.say("setting args: %v", args) + if len(args) != 2 { + c.say("wrong number of arguments") + return + } if c.ctx == nil { - c.ctx = &rhimport.ImportContext{Config: c.conf, RdDb: c.rddb} - c.ctx.UserName = "hugo" + c.ctx = rhimport.NewImportContext(c.conf, c.rddb, "") + } + switch strings.ToLower(args[0]) { + case "username": + c.ctx.UserName = args[1] + case "password": + c.ctx.Password = args[1] + case "sourceuri": + c.ctx.SourceUri = args[1] + case "showid": + if id, err := strconv.ParseUint(args[1], 10, 32); err != nil { + c.say("invalid value (must be an positive integer)") + } else { + c.ctx.ShowId = uint(id) + } + case "clearshowcarts": + if val, err := strconv.ParseBool(args[1]); err != nil { + c.say("invalid value (must be true or false)") + } else { + c.ctx.ClearShowCarts = val + } + case "groupname": + c.ctx.GroupName = args[1] + case "cart": + if cart, err := strconv.ParseUint(args[1], 10, 32); err != nil { + c.say("invalid value (must be an positive integer)") + } else { + c.ctx.Cart = uint(cart) + } + case "clearcart": + if val, err := strconv.ParseBool(args[1]); err != nil { + c.say("invalid value (must be true or false)") + } else { + c.ctx.ClearCart = val + } + case "cut": + if cut, err := strconv.ParseUint(args[1], 10, 32); err != nil { + c.say("invalid value (must be an positive integer)") + } else { + c.ctx.Cut = uint(cut) + } + case "channels": + if channels, err := strconv.ParseUint(args[1], 10, 32); err != nil { + c.say("invalid value (must be an positive integer)") + } else { + c.ctx.Channels = uint(channels) + } + case "normalizationlevel": + if normalizationlevel, err := strconv.ParseInt(args[1], 10, 32); err != nil { + c.say("invalid value (must be an positive integer)") + } else { + c.ctx.NormalizationLevel = int(normalizationlevel) + } + case "autotrimlevel": + if autotrimlevel, err := strconv.ParseInt(args[1], 10, 32); err != nil { + c.say("invalid value (must be an positive integer)") + } else { + c.ctx.AutotrimLevel = int(autotrimlevel) + } + case "usemetadata": + if val, err := strconv.ParseBool(args[1]); err != nil { + c.say("invalid value (must be true or false)") + } else { + c.ctx.UseMetaData = val + } + default: + c.say("unknown parameter, use 'help set' for a list of available parameters") } } @@ -151,6 +222,7 @@ func (c *TelnetClient) handle_cmd_show(args []string) { if c.ctx != nil { c.say(" UserName: %v", c.ctx.UserName) c.say(" Password: %v", c.ctx.Password) + c.say(" SourceUri: %v", c.ctx.SourceUri) c.say(" ShowId: %v", c.ctx.ShowId) c.say(" ClearShowCarts: %v", c.ctx.ClearShowCarts) c.say(" GroupName: %v", c.ctx.GroupName) @@ -161,7 +233,6 @@ func (c *TelnetClient) handle_cmd_show(args []string) { c.say(" NormalizationLevel: %v", c.ctx.NormalizationLevel) c.say(" AutotrimLevel: %v", c.ctx.AutotrimLevel) c.say(" UseMetaData: %v", c.ctx.UseMetaData) - c.say(" SourceUri: %v", c.ctx.SourceUri) } else { c.say("context is empty") } |