From ec66859d34079b0313d90cbc81e738a4b104dc95 Mon Sep 17 00:00:00 2001 From: Radu Ioan Fericean Date: Mon, 12 May 2014 18:44:22 +0300 Subject: [PATCH] console results fix --- cmd/cgr-console/cgr-console.go | 5 +++-- console/account.go | 3 +-- console/account_add.go | 4 ++-- console/accountactions_set.go | 4 ++-- console/action_execute.go | 4 ++-- console/balance_add.go | 6 +++--- console/balance_debit.go | 6 +++--- console/cache_age.go | 3 +-- console/cache_reload.go | 3 ++- console/cache_stats.go | 3 +-- console/callcost.go | 3 ++- console/cdrs_export.go | 3 +-- console/cdrs_rem.go | 4 ++-- console/cost.go | 5 ++--- console/destination.go | 3 +-- console/maxduration.go | 4 ++-- console/ratingprofile_set.go | 3 ++- console/scheduler_reload.go | 4 ++-- console/status.go | 4 ++-- console/triggeredaction_add.go | 4 ++-- 20 files changed, 38 insertions(+), 40 deletions(-) diff --git a/cmd/cgr-console/cgr-console.go b/cmd/cgr-console/cgr-console.go index 45a1ff166..205fda21a 100644 --- a/cmd/cgr-console/cgr-console.go +++ b/cmd/cgr-console/cgr-console.go @@ -86,9 +86,10 @@ func executeCommand(command string) { //log.Printf("Param: %+v", param) if rpcErr := client.Call(cmd.RpcMethod(), param, res); rpcErr != nil { fmt.Println("Error executing command: " + rpcErr.Error()) + } else { + result, _ := json.MarshalIndent(res, "", " ") + fmt.Println(string(result)) } - result, _ := json.MarshalIndent(res, "", " ") - fmt.Println(string(result)) } func main() { diff --git a/console/account.go b/console/account.go index 7ba9f0b02..ae7ee87ff 100644 --- a/console/account.go +++ b/console/account.go @@ -38,7 +38,6 @@ type CmdGetAccount struct { name string rpcMethod string rpcParams *apier.AttrGetAccount - rpcResult engine.Account *CommandExecuter } @@ -58,5 +57,5 @@ func (self *CmdGetAccount) RpcParams() interface{} { } func (self *CmdGetAccount) RpcResult() interface{} { - return &self.rpcResult + return &engine.Account{} } diff --git a/console/account_add.go b/console/account_add.go index 1dc7a19b8..12815b188 100644 --- a/console/account_add.go +++ b/console/account_add.go @@ -34,7 +34,6 @@ type CmdAddAccount struct { name string rpcMethod string rpcParams *apier.AttrSetAccount - rpcResult string *CommandExecuter } @@ -54,5 +53,6 @@ func (self *CmdAddAccount) RpcParams() interface{} { } func (self *CmdAddAccount) RpcResult() interface{} { - return &self.rpcResult + var s string + return &s } diff --git a/console/accountactions_set.go b/console/accountactions_set.go index bd6354136..b4f430aed 100644 --- a/console/accountactions_set.go +++ b/console/accountactions_set.go @@ -34,7 +34,6 @@ type CmdSetAccountActions struct { name string rpcMethod string rpcParams *utils.TPAccountActions - rpcResult string *CommandExecuter } @@ -54,5 +53,6 @@ func (self *CmdSetAccountActions) RpcParams() interface{} { } func (self *CmdSetAccountActions) RpcResult() interface{} { - return &self.rpcResult + var s string + return &s } diff --git a/console/action_execute.go b/console/action_execute.go index 16e5c8e3b..46a83ab65 100644 --- a/console/action_execute.go +++ b/console/action_execute.go @@ -35,7 +35,6 @@ type CmdExecuteAction struct { name string rpcMethod string rpcParams *apier.AttrExecuteAction - rpcResult string *CommandExecuter } @@ -55,5 +54,6 @@ func (self *CmdExecuteAction) RpcParams() interface{} { } func (self *CmdExecuteAction) RpcResult() interface{} { - return &self.rpcResult + var s string + return &s } diff --git a/console/balance_add.go b/console/balance_add.go index cbb1bc47c..f29b71165 100644 --- a/console/balance_add.go +++ b/console/balance_add.go @@ -37,7 +37,6 @@ type CmdAddBalance struct { name string rpcMethod string rpcParams *apier.AttrAddBalance - rpcResult string *CommandExecuter } @@ -50,12 +49,13 @@ func (self *CmdAddBalance) RpcMethod() string { } func (self *CmdAddBalance) RpcParams() interface{} { - if self.rpcParams == nil { + if self.rpcParams == nil { self.rpcParams = &apier.AttrAddBalance{BalanceType: engine.CREDIT} } return self.rpcParams } func (self *CmdAddBalance) RpcResult() interface{} { - return &self.rpcResult + var s string + return &s } diff --git a/console/balance_debit.go b/console/balance_debit.go index 25446ddbc..3327a6198 100644 --- a/console/balance_debit.go +++ b/console/balance_debit.go @@ -36,7 +36,6 @@ type CmdDebitBalance struct { name string rpcMethod string rpcParams *engine.CallDescriptor - rpcResult string clientArgs []string *CommandExecuter } @@ -50,14 +49,15 @@ func (self *CmdDebitBalance) RpcMethod() string { } func (self *CmdDebitBalance) RpcParams() interface{} { - if self.rpcParams == nil { + if self.rpcParams == nil { self.rpcParams = &engine.CallDescriptor{Direction: "*out"} } return self.rpcParams } func (self *CmdDebitBalance) RpcResult() interface{} { - return &self.rpcResult + var s string + return &s } func (self *CmdDebitBalance) ClientArgs() []string { diff --git a/console/cache_age.go b/console/cache_age.go index 023af31e0..50609a5a0 100644 --- a/console/cache_age.go +++ b/console/cache_age.go @@ -34,7 +34,6 @@ type CmdGetCacheAge struct { name string rpcMethod string rpcParams *StringWrapper - rpcResult utils.CachedItemAge *CommandExecuter } @@ -54,5 +53,5 @@ func (self *CmdGetCacheAge) RpcParams() interface{} { } func (self *CmdGetCacheAge) RpcResult() interface{} { - return &self.rpcResult + return &utils.CachedItemAge{} } diff --git a/console/cache_reload.go b/console/cache_reload.go index 3bdbd91f3..2c7375b1f 100644 --- a/console/cache_reload.go +++ b/console/cache_reload.go @@ -54,5 +54,6 @@ func (self *CmdReloadCache) RpcParams() interface{} { } func (self *CmdReloadCache) RpcResult() interface{} { - return &self.rpcResult + var s string + return &s } diff --git a/console/cache_stats.go b/console/cache_stats.go index 75e89869a..da40adbf9 100644 --- a/console/cache_stats.go +++ b/console/cache_stats.go @@ -34,7 +34,6 @@ type CmdGetCacheStats struct { name string rpcMethod string rpcParams *utils.AttrCacheStats - rpcResult utils.CacheStats *CommandExecuter } @@ -54,5 +53,5 @@ func (self *CmdGetCacheStats) RpcParams() interface{} { } func (self *CmdGetCacheStats) RpcResult() interface{} { - return &self.rpcResult + return &utils.CacheStats{} } diff --git a/console/callcost.go b/console/callcost.go index 34651b13a..a56471f84 100644 --- a/console/callcost.go +++ b/console/callcost.go @@ -57,5 +57,6 @@ func (self *CmdGetCallCost) RpcParams() interface{} { } func (self *CmdGetCallCost) RpcResult() interface{} { - return &self.rpcResult + var s string + return &s } diff --git a/console/cdrs_export.go b/console/cdrs_export.go index f88086e10..a6de5d023 100644 --- a/console/cdrs_export.go +++ b/console/cdrs_export.go @@ -34,7 +34,6 @@ type CmdExportCdrs struct { name string rpcMethod string rpcParams *utils.AttrExpFileCdrs - rpcResult utils.ExportedFileCdrs *CommandExecuter } @@ -54,5 +53,5 @@ func (self *CmdExportCdrs) RpcParams() interface{} { } func (self *CmdExportCdrs) RpcResult() interface{} { - return &self.rpcResult + return &utils.ExportedFileCdrs{} } diff --git a/console/cdrs_rem.go b/console/cdrs_rem.go index 5841b6365..fbbcb20e1 100644 --- a/console/cdrs_rem.go +++ b/console/cdrs_rem.go @@ -34,7 +34,6 @@ type CmdRemCdrs struct { name string rpcMethod string rpcParams *utils.AttrRemCdrs - rpcResult string *CommandExecuter } @@ -54,5 +53,6 @@ func (self *CmdRemCdrs) RpcParams() interface{} { } func (self *CmdRemCdrs) RpcResult() interface{} { - return &self.rpcResult + var s string + return &s } diff --git a/console/cost.go b/console/cost.go index 16fe11d07..87b4f316e 100644 --- a/console/cost.go +++ b/console/cost.go @@ -24,7 +24,7 @@ func init() { c := &CmdGetCost{ name: "cost", rpcMethod: "Responder.GetCost", - clientArgs: []string{"Direction", "TOR", "Tenant", "Subject", "Account", "Destination", "TimeStart", "TimeEnd", "CallDuration", "FallbackSubject"}, + clientArgs: []string{"Direction", "Category", "TOR", "Tenant", "Subject", "Account", "Destination", "TimeStart", "TimeEnd", "CallDuration", "FallbackSubject"}, } commands[c.Name()] = c c.CommandExecuter = &CommandExecuter{c} @@ -35,7 +35,6 @@ type CmdGetCost struct { name string rpcMethod string rpcParams *engine.CallDescriptor - rpcResult engine.CallCost clientArgs []string *CommandExecuter } @@ -56,7 +55,7 @@ func (self *CmdGetCost) RpcParams() interface{} { } func (self *CmdGetCost) RpcResult() interface{} { - return &self.rpcResult + return &engine.CallCost{} } func (self *CmdGetCost) ClientArgs() []string { diff --git a/console/destination.go b/console/destination.go index 9e06babeb..30fff13f2 100644 --- a/console/destination.go +++ b/console/destination.go @@ -34,7 +34,6 @@ type CmdGetDestination struct { name string rpcMethod string rpcParams *StringWrapper - rpcResult engine.Destination *CommandExecuter } @@ -54,5 +53,5 @@ func (self *CmdGetDestination) RpcParams() interface{} { } func (self *CmdGetDestination) RpcResult() interface{} { - return &self.rpcResult + return &engine.Destination{} } diff --git a/console/maxduration.go b/console/maxduration.go index 5d4e06872..079ee0d12 100644 --- a/console/maxduration.go +++ b/console/maxduration.go @@ -35,7 +35,6 @@ type CmdGetMaxDuration struct { name string rpcMethod string rpcParams *engine.CallDescriptor - rpcResult *float64 clientArgs []string *CommandExecuter } @@ -56,7 +55,8 @@ func (self *CmdGetMaxDuration) RpcParams() interface{} { } func (self *CmdGetMaxDuration) RpcResult() interface{} { - return &self.rpcResult + var f float64 + return &f } func (self *CmdGetMaxDuration) ClientArgs() []string { diff --git a/console/ratingprofile_set.go b/console/ratingprofile_set.go index 1732fe9d6..f9040729f 100644 --- a/console/ratingprofile_set.go +++ b/console/ratingprofile_set.go @@ -54,5 +54,6 @@ func (self *CmdSetRatingProfile) RpcParams() interface{} { } func (self *CmdSetRatingProfile) RpcResult() interface{} { - return &self.rpcResult + var s string + return &s } diff --git a/console/scheduler_reload.go b/console/scheduler_reload.go index a58bc7dc7..77e58afee 100644 --- a/console/scheduler_reload.go +++ b/console/scheduler_reload.go @@ -32,7 +32,6 @@ type CmdReloadScheduler struct { name string rpcMethod string rpcParams *StringWrapper - rpcResult string *CommandExecuter } @@ -52,5 +51,6 @@ func (self *CmdReloadScheduler) RpcParams() interface{} { } func (self *CmdReloadScheduler) RpcResult() interface{} { - return &self.rpcResult + var s string + return &s } diff --git a/console/status.go b/console/status.go index 4bf66b1b1..e58151f5d 100644 --- a/console/status.go +++ b/console/status.go @@ -31,7 +31,6 @@ type CmdStatus struct { name string rpcMethod string rpcParams *StringWrapper - rpcResult string *CommandExecuter } @@ -51,7 +50,8 @@ func (self *CmdStatus) RpcParams() interface{} { } func (self *CmdStatus) RpcResult() interface{} { - return &self.rpcResult + var s string + return &s } func (self *CmdStatus) ClientArgs() (args []string) { diff --git a/console/triggeredaction_add.go b/console/triggeredaction_add.go index f840e97d2..cd5f4703a 100644 --- a/console/triggeredaction_add.go +++ b/console/triggeredaction_add.go @@ -34,7 +34,6 @@ type CmdAddTriggeredAction struct { name string rpcMethod string rpcParams *apier.AttrAddActionTrigger - rpcResult string *CommandExecuter } @@ -54,5 +53,6 @@ func (self *CmdAddTriggeredAction) RpcParams() interface{} { } func (self *CmdAddTriggeredAction) RpcResult() interface{} { - return &self.rpcResult + var s string + return &s }