Browse Source

Make ls standards compliant

Except we aren't using the standard JshFrame struct. We should probably
have a meeting to discuss how we're going to organize that going
forward.
Ian Adam Naval 5 years ago
parent
commit
58009824b6
1 changed files with 4 additions and 4 deletions
  1. 4
    4
      ls/main.go

+ 4
- 4
ls/main.go View File

@@ -12,7 +12,7 @@ import (
12 12
 func get_fileinfo(f string, size bool, mode bool, inode bool) string {
13 13
 	var stat syscall.Stat_t
14 14
 	var ret string
15
-	ret = "{\"name\":\"" + f + "\""
15
+	ret = "{\"files\": [{\"name\":\"" + f + "\""
16 16
 	if err := syscall.Stat(f, &stat); err != nil {
17 17
 		log.Fatal(err)
18 18
 	}
@@ -25,7 +25,7 @@ func get_fileinfo(f string, size bool, mode bool, inode bool) string {
25 25
 	if inode {
26 26
 		ret = ret + ", \"inode\":" + strconv.FormatUint(stat.Ino, 10)
27 27
 	}
28
-	ret = ret + "}"
28
+	ret = ret + "}]}"
29 29
 	return ret
30 30
 }
31 31
 
@@ -48,7 +48,7 @@ func main() {
48 48
 	root := "." //flag.Arg(0)
49 49
 	dir, _ := ioutil.ReadDir(root)
50 50
 
51
-	fmt.Printf("[\n")
51
+	fmt.Printf("[{\"StdOut\": [\n")
52 52
 
53 53
 	if !a_flag {
54 54
 		for _, entry := range dir {
@@ -71,5 +71,5 @@ func main() {
71 71
 			fmt.Printf("%s\n", get_fileinfo(entry.Name(), size_flag, mode_flag, inode_flag))
72 72
 		}
73 73
 	}
74
-	fmt.Printf("]\n")
74
+	fmt.Printf("], \"StdErr\": []}]\n")
75 75
 }

Loading…
Cancel
Save