Skip to content

Commit

Permalink
- [#] rename MapStringString as OutputStyleMap
Browse files Browse the repository at this point in the history
  • Loading branch information
suntong committed Jan 8, 2023
1 parent 7461e0c commit 9670214
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion cascadia_cli.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Options:
Usage: Raw text output, no trimming of leading and trailing white space

- Name: Piece
Type: MapStringString
Type: OutputStyleMap
Flag: 'p,piece'
Usage: 'sub CSS selectors within -css to split that block up into pieces\n\t\t\tformat: PieceName=[RAW:]selector_string\n\t\t\tRAW: will return the selected as-is; else the text will be returned'

Expand Down
4 changes: 2 additions & 2 deletions cascadia_cliDef.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type rootT struct {
CSS []string `cli:"*c,css" usage:"CSS selectors (can provide more if not using --piece)"`
TextOut bool `cli:"t,text" usage:"Text output for none-block selection mode"`
TextRaw bool `cli:"R,Raw" usage:"Raw text output, no trimming of leading and trailing white space"`
Piece MapStringString `cli:"p,piece" usage:"sub CSS selectors within -css to split that block up into pieces\n\t\t\tformat: PieceName=[OutputStyle:]selector_string\n\t\t\tOutputStyle:\n\t\t\t\tRAW : will return the selected as-is\n\t\t\t\tattr[xxx] : will return the value of an attribute named xxx \n\t\t\telse the text will be returned"`
Piece OutputStyleMap `cli:"p,piece" usage:"sub CSS selectors within -css to split that block up into pieces\n\t\t\tformat: PieceName=[OutputStyle:]selector_string\n\t\t\tOutputStyle:\n\t\t\t\tRAW : will return the selected as-is\n\t\t\t\tattr[xxx] : will return the value of an attribute named xxx \n\t\t\telse the text will be returned"`
Deli string `cli:"d,delimiter" usage:"delimiter for pieces csv output" dft:"\t"`
WrapHTML bool `cli:"w,wrap-html" usage:"wrap up the output with html tags"`
Style string `cli:"y,style" usage:"style component within the wrapped html head"`
Expand Down Expand Up @@ -59,7 +59,7 @@ var root = &cli.Command{
// CSS []string
// TextOut bool
// TextRaw bool
// Piece MapStringString
// Piece OutputStyleMap
// Deli string
// WrapHTML bool
// Style string
Expand Down
8 changes: 4 additions & 4 deletions cascadia_main.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const (
OutputStyleTEXT
)

type MapStringString struct {
type OutputStyleMap struct {
Keys []string
Values map[string]string
OutputStyles map[string]OutputStyle
Expand All @@ -50,7 +50,7 @@ type OptsT struct {
CSS []string
TextOut bool
TextRaw bool
Piece MapStringString
Piece OutputStyleMap
Deli string
WrapHTML bool
Style string
Expand Down Expand Up @@ -209,10 +209,10 @@ func Cascadia(bi io.Reader, bw io.Writer, Opts OptsT) error {

// DecodeSlice implements cli.SliceDecoder
// NOTE: if SliceDecoder not implemented, the Decode method would be only invoked once
func (MapStringString) DecodeSlice() {}
func (OutputStyleMap) DecodeSlice() {}

// Decode implements cli.Decoder interface
func (m *MapStringString) Decode(s string) error {
func (m *OutputStyleMap) Decode(s string) error {
if (m.Values) == nil {
m.Values = make(map[string]string)
m.OutputStyles = make(map[string]OutputStyle)
Expand Down
10 changes: 5 additions & 5 deletions cascadia_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ func TestSelectors(t *testing.T) {
buf := bytes.NewBufferString("")
Opts.CSS, Opts.Piece, Opts.Deli,
Opts.WrapHTML, Opts.TextOut, Opts.TextRaw, Opts.Quiet =
[]string{test.selector}, MapStringString{}, ",",
[]string{test.selector}, OutputStyleMap{}, ",",
false, false, false, false
Cascadia(strings.NewReader(test.HTML), buf, Opts)
got := buf.String()
Expand Down Expand Up @@ -553,7 +553,7 @@ var selectorTests = []selectorTest{
type PieceAttrTest struct {
HTML, selector string
results []string
piece MapStringString
piece OutputStyleMap
}

var PieceAttrTests = []PieceAttrTest{
Expand All @@ -572,7 +572,7 @@ var PieceAttrTests = []PieceAttrTest{
`a3,`,
`a4,`,
},
MapStringString{
OutputStyleMap{
[]string{"id"},
map[string]string{"id": "a"},
map[string]OutputStyle{"id": OutputStyleATTR},
Expand All @@ -594,7 +594,7 @@ var PieceAttrTests = []PieceAttrTest{
`,`,
`,`,
},
MapStringString{
OutputStyleMap{
[]string{"href2"},
map[string]string{"href2": "a"},
map[string]OutputStyle{"href2": OutputStyleATTR},
Expand All @@ -616,7 +616,7 @@ var PieceAttrTests = []PieceAttrTest{
`https://www.google.com/news,`,
`http://news.yahoo.com,`,
},
MapStringString{
OutputStyleMap{
[]string{"href"},
map[string]string{"href": "a"},
map[string]OutputStyle{"href": OutputStyleATTR},
Expand Down

0 comments on commit 9670214

Please sign in to comment.