Skip to content

Commit

Permalink
fix: flag -c para executar código inline havia sido apagada
Browse files Browse the repository at this point in the history
  • Loading branch information
natanfeitosa committed Feb 19, 2024
1 parent abdb05f commit 4f4864b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
13 changes: 8 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,14 @@ func main() {
return
}

// if codigo != "" {
// // fmt.Printf("codigo: %v\n", codigo)
// ptst.InicializaDeString(codigo)
// return
// }
if codigo != "" {
_, err := ptst.ExecutarString(ctx, codigo)

if err != nil {
ptst.LancarErro(err)
}
return
}

playground.Inicializa(ctx, Version, Datetime, Commit)
},
Expand Down
14 changes: 14 additions & 0 deletions ptst/executar.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
package ptst

func ExecutarString(ctx *Contexto, codigo string) (*Modulo, error) {
ast, err := ctx.StringParaAst(codigo)
if err != nil {
return nil, err
}

impl := &ModuloImpl{
Info: ModuloInfo{},
Ast: ast,
}

return ctx.InicializarModulo(impl)
}

func ExecutarArquivo(ctx *Contexto, nome, caminho, curDir string, useSysPaths bool) (*Modulo, error) {
caminhoCalculado, ast, err := ctx.TransformarEmAst(caminho, useSysPaths, curDir)
if err != nil {
Expand Down

0 comments on commit 4f4864b

Please sign in to comment.