Skip to content

Commit

Permalink
Removing reduntant code
Browse files Browse the repository at this point in the history
  • Loading branch information
thekingn committed Jun 15, 2024
1 parent 2cd120c commit 8cd876f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 58 deletions.
37 changes: 4 additions & 33 deletions controller/controller.cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,48 +101,19 @@ func ExecuteRequestorBlockHelper(block *gabs.Container, args ...interface{}) htt
}
}
}

if vm != nil {
preprocess.ProcessVarsInBlock(block, vm)
} else {
preprocess.ProcessVarsInBlock(block, nil)
}

if opts != nil {
cmd, stdinBody = cmdgen.ConstructCommand(block, opts)
} else {
cmd, stdinBody = cmdgen.ConstructCommand(block, opts)
}

preprocess.ProcessVarsInBlock(block, vm)
cmd, stdinBody = cmdgen.ConstructCommand(block, opts)
var resp httpie.ExResponse
var e1 error
if dir != "" {
resp, e1 = cmdexec.ExecCommand(cmd, stdinBody, dir)
} else {
resp, e1 = cmdexec.ExecCommand(cmd, stdinBody, "")
}

resp, e1 = cmdexec.ExecCommand(cmd, stdinBody, dir)
headers := resp.Headers
var headersString string
for key, value := range headers {
headersString += fmt.Sprintf("%s: %s\n", key, value)
}

// TODO: Getting html results for widget
// targetHeader := "text/html"
// isTextHTMLPresent := strings.Contains(headersString, targetHeader)

// if isTextHTMLPresent {
// return resp
// } else {
// fmt.Printf("'%s' is not present in the headers.\n", targetHeader)
if e1 == nil {
chainCode := cmdexec.GenerateChainCode(resp.Body)
if vm != nil {
cmdexec.RunVMCode(chainCode, vm)
} else {
cmdexec.RunVMCode(chainCode, vm)
}
cmdexec.RunVMCode(chainCode, vm)
} else {
fmt.Printf("Error from ExecCommand", e1)
os.Exit(1)
Expand Down
6 changes: 1 addition & 5 deletions controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,7 @@ func extractArgs(args []interface{}) (*goja.Runtime, *lama2cmd.Opts, string) {

func processLama2FileBlock(block *gabs.Container, vm *goja.Runtime, o *lama2cmd.Opts, dir string) httpie.ExResponse {
var resp httpie.ExResponse
if vm != nil && o != nil && dir != "" {
resp = ExecuteRequestorBlock(block, vm, o, dir)
} else {
resp = ExecuteRequestorBlock(block, vm, o, dir)
}
resp = ExecuteRequestorBlock(block, vm, o, dir)
return resp
}

Expand Down
23 changes: 3 additions & 20 deletions controller/controller.wasm.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ func ProcessWasmInput(data string) (httpie.ExResponse, *lama2cmd.Opts) {

// Print the parsedAPI value
fmt.Printf("Parsed API: %+v\n", parsedAPI)
fmt.Println(parsedAPI)
return HandleParsedFile(parsedAPI)
}

Expand All @@ -66,28 +65,13 @@ func ExecuteRequestorBlockHelper(block *gabs.Container, args ...interface{}) htt
}
}
}

if vm != nil {
preprocess.ProcessVarsInBlock(block, vm)
} else {
preprocess.ProcessVarsInBlock(block, vm)
}
preprocess.ProcessVarsInBlock(block, vm)
var cmd []string
var stdinBody string
if opts != nil {
cmd, stdinBody = cmdgen.ConstructCommand(block, opts)
} else {
cmd, stdinBody = cmdgen.ConstructCommand(block, opts)
}

cmd, stdinBody = cmdgen.ConstructCommand(block, opts)
var resp httpie.ExResponse
var e1 error
if dir != "" {
resp, e1 = cmdexec.ExecCommand(cmd, stdinBody, dir)
} else {
resp, e1 = cmdexec.ExecCommand(cmd, stdinBody, dir)
}

resp, e1 = cmdexec.ExecCommand(cmd, stdinBody, dir)
headers := resp.Headers
var headersString string
for key, value := range headers {
Expand All @@ -108,7 +92,6 @@ func ExecuteRequestorBlockHelper(block *gabs.Container, args ...interface{}) htt
cmdexec.RunVMCode(chainCode, vm)
} else {
ExecuteJsCodeWasm(chainCode)
// js.Global().Call("eval", chainCode)
}
} else {
fmt.Println("Error from ExecCommand", e1)
Expand Down

0 comments on commit 8cd876f

Please sign in to comment.