Skip to content

Commit

Permalink
even more
Browse files Browse the repository at this point in the history
  • Loading branch information
Selyss committed Nov 16, 2023
1 parent 44cf524 commit 9ddfc16
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 5 deletions.
3 changes: 2 additions & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@ func parseArgs() *assembuddy.CLIOptions {

func main() {
opts := parseArgs()
assembuddy.QueryASM(opts)
// assembuddy.QueryASM(opts)
fmt.Println(assembuddy.ListQueryMatches(opts.Syscall))
}
4 changes: 0 additions & 4 deletions pkg/assembuddy/asm.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ func QueryASM(opts *CLIOptions) {
selectedName = syscall
}

if selectedName == "" {
log.Fatalf("No syscall selected.")
}

selectedSyscall, err := getSyscallDetails(arch, selectedName)
if err != nil {
log.Fatalf("Error fetching syscall details: %s", err)
Expand Down
39 changes: 39 additions & 0 deletions pkg/assembuddy/listOptions.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package assembuddy

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

// ListOptions provides options for listing assemblies.
func ListArchSyscalls() {
}

func ListQueryMatches(query string) ([]string, error) {
url := fmt.Sprintf("https://api.syscall.sh/v1/syscalls/%s", query)
resp, err := http.Get(url)
if err != nil {
return nil, err
}
defer resp.Body.Close()

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

var syscalls []Syscall

if err := json.Unmarshal(body, &syscalls); err != nil {
return nil, err
}

var syscallNames []string
for _, syscall := range syscalls {
syscallNames = append(syscallNames, syscall.Name)
}

return syscallNames, nil
}

0 comments on commit 9ddfc16

Please sign in to comment.