Skip to content

Commit

Permalink
Added usage() to jsc
Browse files Browse the repository at this point in the history
  • Loading branch information
N-Holzschuch committed Apr 1, 2020
1 parent 8e08a2b commit a3403e8
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions jsc.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,24 @@ func convertCArguments(argc: Int32, argv: UnsafeMutablePointer<UnsafeMutablePoin
args.append(arg)

}

return args
}

func printUsage() {
fputs("Usage: jsc file.js\n", thread_stdout)
}

// execute JavaScript:
@_cdecl("jsc")
public func jsc(argc: Int32, argv: UnsafeMutablePointer<UnsafeMutablePointer<Int8>?>?) -> Int32 {
guard let args = convertCArguments(argc: argc, argv: argv) else { return 0 }
if (argc != 2) {
printUsage()
return 0
}
guard let args = convertCArguments(argc: argc, argv: argv) else {
printUsage()
return 0
}
let command = args[1]
let fileName = FileManager().currentDirectoryPath + "/" + command
do {
Expand Down

0 comments on commit a3403e8

Please sign in to comment.