mirror of
https://github.com/aykhans/sarin.git
synced 2026-02-28 14:59:14 +00:00
Rename Append to Merge, replace strings_Join with slice_Join, and auto-detect non-TTY output
- Rename Append to Merge on Cookies, Headers, and Params types and simplify Parse to use direct append - Replace strings_Join(sep, ...values) with slice_Join(slice, sep) for consistency with slice-based template functions - Auto-enable quiet mode when stdout is not a terminal - Remove ErrCLINoArgs check to allow running sarin without arguments - Add -it flag to Docker examples in docs
This commit is contained in:
@@ -15,7 +15,7 @@ func (cookies Cookies) GetValue(key string) *[]string {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (cookies *Cookies) Append(cookie ...Cookie) {
|
||||
func (cookies *Cookies) Merge(cookie ...Cookie) {
|
||||
for _, c := range cookie {
|
||||
if item := cookies.GetValue(c.Key); item != nil {
|
||||
*item = append(*item, c.Value...)
|
||||
@@ -27,7 +27,7 @@ func (cookies *Cookies) Append(cookie ...Cookie) {
|
||||
|
||||
func (cookies *Cookies) Parse(rawValues ...string) {
|
||||
for _, rawValue := range rawValues {
|
||||
cookies.Append(*ParseCookie(rawValue))
|
||||
*cookies = append(*cookies, *ParseCookie(rawValue))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -250,10 +250,6 @@ func (e TemplateRenderError) Unwrap() error {
|
||||
|
||||
// ======================================== CLI ========================================
|
||||
|
||||
var (
|
||||
ErrCLINoArgs = errors.New("CLI expects arguments but received none")
|
||||
)
|
||||
|
||||
type CLIUnexpectedArgsError struct {
|
||||
Args []string
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ func (headers Headers) GetValue(key string) *[]string {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (headers *Headers) Append(header ...Header) {
|
||||
func (headers *Headers) Merge(header ...Header) {
|
||||
for _, h := range header {
|
||||
if item := headers.GetValue(h.Key); item != nil {
|
||||
*item = append(*item, h.Value...)
|
||||
@@ -36,7 +36,7 @@ func (headers *Headers) Append(header ...Header) {
|
||||
|
||||
func (headers *Headers) Parse(rawValues ...string) {
|
||||
for _, rawValue := range rawValues {
|
||||
headers.Append(*ParseHeader(rawValue))
|
||||
*headers = append(*headers, *ParseHeader(rawValue))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ func (params Params) GetValue(key string) *[]string {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (params *Params) Append(param ...Param) {
|
||||
func (params *Params) Merge(param ...Param) {
|
||||
for _, p := range param {
|
||||
if item := params.GetValue(p.Key); item != nil {
|
||||
*item = append(*item, p.Value...)
|
||||
@@ -27,7 +27,7 @@ func (params *Params) Append(param ...Param) {
|
||||
|
||||
func (params *Params) Parse(rawValues ...string) {
|
||||
for _, rawValue := range rawValues {
|
||||
params.Append(*ParseParam(rawValue))
|
||||
*params = append(*params, *ParseParam(rawValue))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user