From a0a416e7762fcdcc066617da8083b0372b87155c Mon Sep 17 00:00:00 2001 From: Charlie Stanton Date: Thu, 20 Apr 2023 09:59:59 +0100 Subject: Remove filters and various commands that are no longer wanted These have all been made redundant by the incredible substitute command --- main/command.go | 60 --------------------------------------------------------- 1 file changed, 60 deletions(-) (limited to 'main/command.go') diff --git a/main/command.go b/main/command.go index e676255..7d44309 100644 --- a/main/command.go +++ b/main/command.go @@ -16,41 +16,6 @@ func (cmd PrintValueCommand) exec(state *ProgramState) { } } -type ToggleTerminalCommand struct {} -func (cmd ToggleTerminalCommand) exec(state *ProgramState) { - toggled := map[walk.TerminalValue]walk.TerminalValue { - walk.ArrayBegin: walk.MapBegin, - walk.ArrayEnd: walk.MapEnd, - walk.MapBegin: walk.ArrayBegin, - walk.MapEnd: walk.ArrayEnd, - } - - for i := range state.value { - terminal, isTerminal := state.value[i].(walk.TerminalValue) - if !isTerminal { - continue - } - state.value[i] = toggled[terminal] - } -} - -type FilteredCommand struct { - filter Filter - command Command -} -func (cmd FilteredCommand) exec(state *ProgramState) { - path := walk.PathFromWalkValues(state.path) - for _, value := range state.value { - if cmd.filter.exec(walk.WalkItem { - Value: value, - Path: path, - }) { - cmd.command.exec(state) - return - } - } -} - type SequenceCommand struct { commands []Command } @@ -60,22 +25,6 @@ func (cmd SequenceCommand) exec(state *ProgramState) { } } -type AppendLiteralCommand struct { - values []walk.WalkValue -} -func (cmd AppendLiteralCommand) exec(state *ProgramState) { - state.value = append(state.value, cmd.values...) -} - -type PrependLiteralCommand struct { - values []walk.WalkValue -} -func (cmd PrependLiteralCommand) exec(state *ProgramState) { - var newItems []walk.WalkValue - newItems = append(newItems, cmd.values...) - state.value = append(newItems, state.value...) -} - type NextCommand struct {} func (cmd NextCommand) exec(state *ProgramState) { nextItem := <- state.in @@ -90,15 +39,6 @@ func (cmd AppendNextCommand) exec(state *ProgramState) { state.path = nextItem.Path.ToWalkValues() } -type PrintLiteralsCommand struct { - items []walk.WalkItem -} -func (cmd PrintLiteralsCommand) exec(state *ProgramState) { - for _, item := range cmd.items { - state.out <- item - } -} - type DeleteAllCommand struct {} func (cmd DeleteAllCommand) exec(state *ProgramState) { state.path = nil -- cgit v1.2.3