mirror of
https://github.com/aykhans/dodo.git
synced 2025-04-20 11:11:26 +00:00
Merge pull request #28 from aykhans/refactor/config-print
Refactor config/print
This commit is contained in:
commit
b224912638
@ -11,7 +11,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
VERSION string = "0.5.0"
|
VERSION string = "0.5.1"
|
||||||
DefaultUserAgent string = "Dodo/" + VERSION
|
DefaultUserAgent string = "Dodo/" + VERSION
|
||||||
ProxyCheckURL string = "https://www.google.com"
|
ProxyCheckURL string = "https://www.google.com"
|
||||||
DefaultMethod string = "GET"
|
DefaultMethod string = "GET"
|
||||||
@ -64,7 +64,7 @@ func (config *RequestConfig) Print() {
|
|||||||
t.AppendSeparator()
|
t.AppendSeparator()
|
||||||
t.AppendRow(table.Row{"Cookies", utils.MarshalJSON(config.Cookies, 3)})
|
t.AppendRow(table.Row{"Cookies", utils.MarshalJSON(config.Cookies, 3)})
|
||||||
t.AppendSeparator()
|
t.AppendSeparator()
|
||||||
t.AppendRow(table.Row{"Proxies", utils.MarshalJSON(config.Proxies, 3)})
|
t.AppendRow(table.Row{"Proxies Count", len(config.Proxies)})
|
||||||
t.AppendSeparator()
|
t.AppendSeparator()
|
||||||
t.AppendRow(table.Row{"Body", utils.MarshalJSON(config.Body, 3)})
|
t.AppendRow(table.Row{"Body", utils.MarshalJSON(config.Body, 3)})
|
||||||
|
|
||||||
|
@ -2,8 +2,8 @@ package utils
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func MarshalJSON(v any, maxSliceSize uint) string {
|
func MarshalJSON(v any, maxSliceSize uint) string {
|
||||||
@ -17,7 +17,7 @@ func MarshalJSON(v any, maxSliceSize uint) string {
|
|||||||
return "{}"
|
return "{}"
|
||||||
}
|
}
|
||||||
|
|
||||||
return strings.Replace(string(data), `"..."`, "...", -1)
|
return string(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
func truncateLists(v interface{}, maxItems int) interface{} {
|
func truncateLists(v interface{}, maxItems int) interface{} {
|
||||||
@ -28,7 +28,7 @@ func truncateLists(v interface{}, maxItems int) interface{} {
|
|||||||
if rv.Len() > maxItems {
|
if rv.Len() > maxItems {
|
||||||
newSlice := reflect.MakeSlice(rv.Type(), maxItems, maxItems)
|
newSlice := reflect.MakeSlice(rv.Type(), maxItems, maxItems)
|
||||||
reflect.Copy(newSlice, rv.Slice(0, maxItems))
|
reflect.Copy(newSlice, rv.Slice(0, maxItems))
|
||||||
newSlice = reflect.Append(newSlice, reflect.ValueOf("..."))
|
newSlice = reflect.Append(newSlice, reflect.ValueOf(fmt.Sprintf("...(%d more)", rv.Len()-maxItems)))
|
||||||
return newSlice.Interface()
|
return newSlice.Interface()
|
||||||
}
|
}
|
||||||
case reflect.Map:
|
case reflect.Map:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user