Skip to content

Commit

Permalink
refactor logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Selyss committed Nov 19, 2023
1 parent 9ddfc16 commit 3c4624d
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 244 deletions.
23 changes: 19 additions & 4 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,23 @@ package main

import (
"fmt"
"log"
"os"

"github.com/Selyss/AssemBuddy/pkg/assembuddy"
"github.com/akamensky/argparse"
// tea "github.com/charmbracelet/bubbletea"
)

func parseArgs() *assembuddy.CLIOptions {
opts := &assembuddy.CLIOptions{}
type CLIOptions struct {
Syscall string
Arch string
ListQueryMatches bool
ListArchQueries bool
}

func parseArgs() *CLIOptions {
opts := &CLIOptions{}

parser := argparse.NewParser("AssemBuddy", "Tool for querying assembly keywords")
query := parser.String("q", "query", &argparse.Options{Help: "Search query"})
Expand All @@ -34,6 +42,13 @@ func parseArgs() *assembuddy.CLIOptions {

func main() {
opts := parseArgs()
// assembuddy.QueryASM(opts)
fmt.Println(assembuddy.ListQueryMatches(opts.Syscall))
if opts.Syscall != "" {
fmt.Println("Searching for Syscall: ", opts.Syscall)
}
if opts.Arch != "" {
err, table := assembuddy.GetFromArchitecture(opts.Syscall)

Check failure on line 49 in cmd/main.go

View workflow job for this annotation

GitHub Actions / build

table declared and not used
if err != nil {
log.Fatalf("Error: %s", err)
}
}
}
113 changes: 0 additions & 113 deletions pkg/assembuddy/asm.go

This file was deleted.

39 changes: 0 additions & 39 deletions pkg/assembuddy/listOptions.go

This file was deleted.

4 changes: 4 additions & 0 deletions pkg/assembuddy/renderTable.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package assembuddy

func RenderTable(table []string) {
}
45 changes: 45 additions & 0 deletions pkg/assembuddy/requestTable.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package assembuddy

import (
"encoding/json"
"io"
"net/http"
)

type SystemCall struct {
Arch string `json:"arch"`
Name string `json:"name"`
ReturnValue string `json:"return"`
Arg0 string `json:"arg0"`
Arg1 string `json:"arg1"`
Arg2 string `json:"arg2"`
Arg3 string `json:"arg3"`
Arg4 string `json:"arg4"`
Arg5 string `json:"arg5"`
Nr int `json:"nr"`
}

func fetchData(endpointURL string) ([]SystemCall, error) {
response, err := http.Get(endpointURL)
if err != nil {
return nil, err
}
defer response.Body.Close()

body, err := io.ReadAll(response.Body)
if err != nil {
return nil, err
}

var systemCalls []SystemCall
err = json.Unmarshal(body, &systemCalls)
if err != nil {
return nil, err
}

return systemCalls, nil
}

func GetFromArchitecture(arch string) ([]string, error) {
return nil, nil
}
88 changes: 0 additions & 88 deletions pkg/assembuddy/syscall.go

This file was deleted.

0 comments on commit 3c4624d

Please sign in to comment.