1- use crate :: types:: command:: { Command , CommandArgs , CommandResult , GoToValue } ;
1+ use crate :: types:: command:: { Command , CommandInvocationContext , CommandResult , GoToValue } ;
22use crate :: types:: instruction:: {
33 Instruction , InstructionType , PreProcessInstruction , ScriptInstruction ,
44} ;
@@ -15,11 +15,11 @@ impl Command for SetCommand {
1515 Box :: new ( ( * self ) . clone ( ) )
1616 }
1717
18- fn run ( & self , arguments : CommandArgs ) -> CommandResult {
19- let output = if arguments . args . is_empty ( ) {
18+ fn run ( & self , context : CommandInvocationContext ) -> CommandResult {
19+ let output = if context . arguments . is_empty ( ) {
2020 None
2121 } else {
22- Some ( arguments . args [ 0 ] . clone ( ) )
22+ Some ( context . arguments [ 0 ] . clone ( ) )
2323 } ;
2424
2525 CommandResult :: Continue ( output)
@@ -38,11 +38,11 @@ impl Command for ExitCommand {
3838 Box :: new ( ( * self ) . clone ( ) )
3939 }
4040
41- fn run ( & self , arguments : CommandArgs ) -> CommandResult {
42- let output = if arguments . args . is_empty ( ) {
41+ fn run ( & self , context : CommandInvocationContext ) -> CommandResult {
42+ let output = if context . arguments . is_empty ( ) {
4343 None
4444 } else {
45- Some ( arguments . args [ 0 ] . clone ( ) )
45+ Some ( context . arguments [ 0 ] . clone ( ) )
4646 } ;
4747
4848 CommandResult :: Exit ( output)
@@ -61,16 +61,16 @@ impl Command for OnErrorCommand {
6161 Box :: new ( ( * self ) . clone ( ) )
6262 }
6363
64- fn run ( & self , arguments : CommandArgs ) -> CommandResult {
64+ fn run ( & self , context : CommandInvocationContext ) -> CommandResult {
6565 let mut index = 0 ;
66- for argument in arguments . args {
66+ for argument in context . arguments {
6767 index = index + 1 ;
68- arguments
68+ context
6969 . variables
7070 . insert ( index. to_string ( ) , argument. clone ( ) ) ;
7171 }
7272
73- writeln ! ( arguments . env. out, "{}" , "test" ) . unwrap ( ) ;
73+ writeln ! ( context . env. out, "{}" , "test" ) . unwrap ( ) ;
7474
7575 CommandResult :: Continue ( None )
7676 }
@@ -88,7 +88,7 @@ impl Command for ErrorCommand {
8888 Box :: new ( ( * self ) . clone ( ) )
8989 }
9090
91- fn run ( & self , _arguments : CommandArgs ) -> CommandResult {
91+ fn run ( & self , _context : CommandInvocationContext ) -> CommandResult {
9292 CommandResult :: Error ( "test" . to_string ( ) )
9393 }
9494}
@@ -105,7 +105,7 @@ impl Command for CrashCommand {
105105 Box :: new ( ( * self ) . clone ( ) )
106106 }
107107
108- fn run ( & self , _arguments : CommandArgs ) -> CommandResult {
108+ fn run ( & self , _context : CommandInvocationContext ) -> CommandResult {
109109 CommandResult :: Crash ( "test" . to_string ( ) )
110110 }
111111}
@@ -122,11 +122,14 @@ impl Command for GoToLabelCommand {
122122 Box :: new ( ( * self ) . clone ( ) )
123123 }
124124
125- fn run ( & self , arguments : CommandArgs ) -> CommandResult {
126- let ( output, label) = if arguments . args . is_empty ( ) {
125+ fn run ( & self , context : CommandInvocationContext ) -> CommandResult {
126+ let ( output, label) = if context . arguments . is_empty ( ) {
127127 ( None , "target" . to_string ( ) )
128128 } else {
129- ( Some ( arguments. args [ 0 ] . clone ( ) ) , arguments. args [ 0 ] . clone ( ) )
129+ (
130+ Some ( context. arguments [ 0 ] . clone ( ) ) ,
131+ context. arguments [ 0 ] . clone ( ) ,
132+ )
130133 } ;
131134
132135 CommandResult :: GoTo ( output, GoToValue :: Label ( label) )
@@ -145,13 +148,13 @@ impl Command for GoToLineCommand {
145148 Box :: new ( ( * self ) . clone ( ) )
146149 }
147150
148- fn run ( & self , arguments : CommandArgs ) -> CommandResult {
149- let ( output, line) = if arguments . args . is_empty ( ) {
151+ fn run ( & self , context : CommandInvocationContext ) -> CommandResult {
152+ let ( output, line) = if context . arguments . is_empty ( ) {
150153 ( None , 900 )
151154 } else {
152155 (
153- Some ( arguments . args [ 0 ] . clone ( ) ) ,
154- arguments . args [ 0 ] . clone ( ) . parse ( ) . unwrap ( ) ,
156+ Some ( context . arguments [ 0 ] . clone ( ) ) ,
157+ context . arguments [ 0 ] . clone ( ) . parse ( ) . unwrap ( ) ,
155158 )
156159 } ;
157160
@@ -175,7 +178,7 @@ impl Command for TestCommand1 {
175178 Box :: new ( ( * self ) . clone ( ) )
176179 }
177180
178- fn run ( & self , _arguments : CommandArgs ) -> CommandResult {
181+ fn run ( & self , _context : CommandInvocationContext ) -> CommandResult {
179182 CommandResult :: Continue ( None )
180183 }
181184}
@@ -196,7 +199,7 @@ impl Command for TestCommand2 {
196199 Box :: new ( ( * self ) . clone ( ) )
197200 }
198201
199- fn run ( & self , _arguments : CommandArgs ) -> CommandResult {
202+ fn run ( & self , _context : CommandInvocationContext ) -> CommandResult {
200203 CommandResult :: Continue ( None )
201204 }
202205}
@@ -217,7 +220,7 @@ impl Command for TestCommand3 {
217220 Box :: new ( ( * self ) . clone ( ) )
218221 }
219222
220- fn run ( & self , _arguments : CommandArgs ) -> CommandResult {
223+ fn run ( & self , _context : CommandInvocationContext ) -> CommandResult {
221224 CommandResult :: Continue ( None )
222225 }
223226}
@@ -238,7 +241,7 @@ impl Command for TestCommand4 {
238241 Box :: new ( ( * self ) . clone ( ) )
239242 }
240243
241- fn run ( & self , _arguments : CommandArgs ) -> CommandResult {
244+ fn run ( & self , _context : CommandInvocationContext ) -> CommandResult {
242245 CommandResult :: Continue ( None )
243246 }
244247}
0 commit comments