| 1 | package cliscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/internal/cli`/ |
| 2 | |
| 3 | import ( |
| 4 | "fmtscip-go gomod github.com/golang/go/src go1.25 fmt/" |
| 5 | "reflectscip-go gomod github.com/golang/go/src go1.25 reflect/" |
| 6 | "stringsscip-go gomod github.com/golang/go/src go1.25 strings/" |
| 7 | |
| 8 | "github.com/alecthomas/kongscip-go gomod github.com/alecthomas/kong v1.14.0 `github.com/alecthomas/kong`/" |
| 9 | "github.com/tomwright/dasel/v3/parsingscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/" |
| 10 | ) |
| 11 | |
| 12 | type extReadWriteFlagscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/internal/cli`/extReadWriteFlag# struct { |
| 13 | Namescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/internal/cli`/extReadWriteFlag#Name. string |
| 14 | Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/internal/cli`/extReadWriteFlag#Value. string |
| 15 | } |
| 16 | |
| 17 | type extReadWriteFlagsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/internal/cli`/extReadWriteFlags# *[]extReadWriteFlagscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/internal/cli`/extReadWriteFlag# |
| 18 | |
| 19 | func applyReaderFlagsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/internal/cli`/applyReaderFlags().(readerOptions *parsingscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/.ReaderOptionsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/ReaderOptions#, readerFlags extReadWriteFlagsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/internal/cli`/extReadWriteFlags#, readWriterFlags extReadWriteFlagsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/internal/cli`/extReadWriteFlags#) { |
| 20 | if readWriterFlags != nil { |
| 21 | for _, flag := range *readWriterFlags { |
| 22 | readerOptions.Extscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/ReaderOptions#Ext.[flag.Namescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/internal/cli`/extReadWriteFlag#Name.] = flag.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/internal/cli`/extReadWriteFlag#Value. |
| 23 | } |
| 24 | } |
| 25 | if readerFlags != nil { |
| 26 | for _, flag := range *readerFlags { |
| 27 | readerOptions.Extscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/ReaderOptions#Ext.[flag.Namescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/internal/cli`/extReadWriteFlag#Name.] = flag.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/internal/cli`/extReadWriteFlag#Value. |
| 28 | } |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | func applyWriterFlagsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/internal/cli`/applyWriterFlags().(writerOptions *parsingscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/.WriterOptionsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/WriterOptions#, writerFlags extReadWriteFlagsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/internal/cli`/extReadWriteFlags#, readWriterFlags extReadWriteFlagsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/internal/cli`/extReadWriteFlags#) { |
| 33 | if readWriterFlags != nil { |
| 34 | for _, flag := range *readWriterFlags { |
| 35 | writerOptions.Extscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/WriterOptions#Ext.[flag.Namescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/internal/cli`/extReadWriteFlag#Name.] = flag.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/internal/cli`/extReadWriteFlag#Value. |
| 36 | } |
| 37 | } |
| 38 | if writerFlags != nil { |
| 39 | for _, flag := range *writerFlags { |
| 40 | writerOptions.Extscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/parsing`/WriterOptions#Ext.[flag.Namescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/internal/cli`/extReadWriteFlag#Name.] = flag.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/internal/cli`/extReadWriteFlag#Value. |
| 41 | } |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | type extReadWriteFlagMapperscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/internal/cli`/extReadWriteFlagMapper# struct { |
| 46 | } |
| 47 | |
| 48 | func (vm *extReadWriteFlagMapperscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/internal/cli`/extReadWriteFlagMapper#) Decodescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/internal/cli`/extReadWriteFlagMapper#Decode().(ctx *kongscip-go gomod github.com/alecthomas/kong v1.14.0 `github.com/alecthomas/kong`/.DecodeContextscip-go gomod github.com/alecthomas/kong v1.14.0 `github.com/alecthomas/kong`/DecodeContext#, target reflectscip-go gomod github.com/golang/go/src go1.25 reflect/.Valuescip-go gomod github.com/golang/go/src go1.25 reflect/Value#) error { |
| 49 | t := ctx.Scanscip-go gomod github.com/alecthomas/kong v1.14.0 `github.com/alecthomas/kong`/DecodeContext#Scan..Popscip-go gomod github.com/alecthomas/kong v1.14.0 `github.com/alecthomas/kong`/Scanner#Pop().() |
| 50 | |
| 51 | strVal, ok := t.Valuescip-go gomod github.com/alecthomas/kong v1.14.0 `github.com/alecthomas/kong`/Token#Value..(string) |
| 52 | if !ok { |
| 53 | return fmtscip-go gomod github.com/golang/go/src go1.25 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25 fmt/Errorf().("expected string value for variable") |
| 54 | } |
| 55 | |
| 56 | nameValueSplit := stringsscip-go gomod github.com/golang/go/src go1.25 strings/.SplitNscip-go gomod github.com/golang/go/src go1.25 strings/SplitN().(strVal, "=", 2) |
| 57 | if len(nameValueSplit) != 2 { |
| 58 | return fmtscip-go gomod github.com/golang/go/src go1.25 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25 fmt/Errorf().("invalid read/write flag format, expect foo=bar") |
| 59 | } |
| 60 | |
| 61 | res := extReadWriteFlagscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/internal/cli`/extReadWriteFlag#{ |
| 62 | Namescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/internal/cli`/extReadWriteFlag#Name.: nameValueSplit[0], |
| 63 | Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/internal/cli`/extReadWriteFlag#Value.: nameValueSplit[1], |
| 64 | } |
| 65 | |
| 66 | target.Elemscip-go gomod github.com/golang/go/src go1.25 reflect/Value#Elem().().Setscip-go gomod github.com/golang/go/src go1.25 reflect/Value#Set().(reflectscip-go gomod github.com/golang/go/src go1.25 reflect/.Appendscip-go gomod github.com/golang/go/src go1.25 reflect/Append().(target.Elemscip-go gomod github.com/golang/go/src go1.25 reflect/Value#Elem().(), reflectscip-go gomod github.com/golang/go/src go1.25 reflect/.ValueOfscip-go gomod github.com/golang/go/src go1.25 reflect/ValueOf().(res))) |
| 67 | |
| 68 | return nil |
| 69 | } |