@@ -279,35 +279,54 @@ func (s *Session) Eval(in string) (string, bytes.Buffer, error) {
279279 // Split the lines of the input to check for special commands.
280280 inLines := strings .Split (in , "\n " )
281281 var nonImportLines []string
282- for _ , line := range inLines {
282+ for idx , line := range inLines {
283283
284284 // Extract non-special lines.
285- if ! strings .HasPrefix (line , "import" ) && ! strings .HasPrefix (line , ":" ) {
285+ trimLine := strings .TrimSpace (line )
286+ if ! strings .HasPrefix (line , "import" ) && ! strings .HasPrefix (line , ":" ) && ! strings .HasPrefix (trimLine , "\" " ) && ! strings .HasPrefix (line , ")" ) {
286287 nonImportLines = append (nonImportLines , line )
287288 continue
288289 }
289290
290291 // Process special commands.
292+ var args []string
291293 for _ , command := range commands {
292294
295+ // Clear the args.
296+ args = []string {}
297+
293298 // Extract any argument provided with the special command.
294299 arg := strings .TrimPrefix (line , ":" + command .name )
295300 if command .name == "import" {
296301 arg = strings .TrimPrefix (arg , "import" )
297302 }
298- if arg == line {
303+ switch {
304+ case arg == line :
299305 continue
306+ case strings .HasPrefix (strings .TrimSpace (arg ), "(" ):
307+ advance := 1
308+ currentLine := inLines [idx + advance ]
309+ for ! strings .Contains (currentLine , ")" ) {
310+ fmt .Println (currentLine )
311+ args = append (args , currentLine )
312+ advance ++
313+ currentLine = inLines [idx + advance ]
314+ }
315+ default :
316+ args = append (args , arg )
300317 }
301318
302319 // Apply the action associated with the special command.
303- if arg == "" || strings .HasPrefix (arg , " " ) {
304- arg = strings .TrimSpace (arg )
305- _ , err := command .action (s , arg )
306- if err != nil {
307- if err == ErrQuit {
308- return "" , bytes.Buffer {}, err
320+ for _ , arg = range args {
321+ if arg == "" || strings .HasPrefix (arg , " " ) {
322+ arg = strings .TrimSpace (arg )
323+ _ , err := command .action (s , arg )
324+ if err != nil {
325+ if err == ErrQuit {
326+ return "" , bytes.Buffer {}, err
327+ }
328+ errorf ("%s: %s" , command .name , err )
309329 }
310- errorf ("%s: %s" , command .name , err )
311330 }
312331 }
313332 }
0 commit comments