@@ -278,35 +278,54 @@ func (s *Session) Eval(in string) (string, bytes.Buffer, error) {
278
278
// Split the lines of the input to check for special commands.
279
279
inLines := strings .Split (in , "\n " )
280
280
var nonImportLines []string
281
- for _ , line := range inLines {
281
+ for idx , line := range inLines {
282
282
283
283
// Extract non-special lines.
284
- if ! strings .HasPrefix (line , "import" ) && ! strings .HasPrefix (line , ":" ) {
284
+ trimLine := strings .TrimSpace (line )
285
+ if ! strings .HasPrefix (line , "import" ) && ! strings .HasPrefix (line , ":" ) && ! strings .HasPrefix (trimLine , "\" " ) && ! strings .HasPrefix (line , ")" ) {
285
286
nonImportLines = append (nonImportLines , line )
286
287
continue
287
288
}
288
289
289
290
// Process special commands.
291
+ var args []string
290
292
for _ , command := range commands {
291
293
294
+ // Clear the args.
295
+ args = []string {}
296
+
292
297
// Extract any argument provided with the special command.
293
298
arg := strings .TrimPrefix (line , ":" + command .name )
294
299
if command .name == "import" {
295
300
arg = strings .TrimPrefix (arg , "import" )
296
301
}
297
- if arg == line {
302
+ switch {
303
+ case arg == line :
298
304
continue
305
+ case strings .HasPrefix (strings .TrimSpace (arg ), "(" ):
306
+ advance := 1
307
+ currentLine := inLines [idx + advance ]
308
+ for ! strings .Contains (currentLine , ")" ) {
309
+ fmt .Println (currentLine )
310
+ args = append (args , currentLine )
311
+ advance ++
312
+ currentLine = inLines [idx + advance ]
313
+ }
314
+ default :
315
+ args = append (args , arg )
299
316
}
300
317
301
318
// Apply the action associated with the special command.
302
- if arg == "" || strings .HasPrefix (arg , " " ) {
303
- arg = strings .TrimSpace (arg )
304
- _ , err := command .action (s , arg )
305
- if err != nil {
306
- if err == ErrQuit {
307
- return "" , bytes.Buffer {}, err
319
+ for _ , arg = range args {
320
+ if arg == "" || strings .HasPrefix (arg , " " ) {
321
+ arg = strings .TrimSpace (arg )
322
+ _ , err := command .action (s , arg )
323
+ if err != nil {
324
+ if err == ErrQuit {
325
+ return "" , bytes.Buffer {}, err
326
+ }
327
+ errorf ("%s: %s" , command .name , err )
308
328
}
309
- errorf ("%s: %s" , command .name , err )
310
329
}
311
330
}
312
331
}
0 commit comments