-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathMain.swift.diff
52 lines (50 loc) · 2.08 KB
/
Main.swift.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
@@ -1,32 +1,27 @@
import Foundation
@main
public struct Main {
public static func main() throws {
- // You can use print statements as follows for debugging, they'll be visible when running tests.
- print("Logs from your program will appear here!")
+ guard CommandLine.argc >= 2 else {
+ print("usage: mygit <command> [<args>...]")
+ return
+ }
- // Uncomment this block to pass the first stage
- //
- // guard CommandLine.argc >= 2 else {
- // print("usage: mygit <command> [<args>...]")
- // return
- // }
- //
- // let command = CommandLine.arguments[1]
- // switch command {
- // case "init":
- // let fileManager = FileManager.default
- //
- // try fileManager.createDirectory(atPath: ".git", withIntermediateDirectories: false)
- // try fileManager.createDirectory(atPath: ".git/objects", withIntermediateDirectories: false)
- // try fileManager.createDirectory(atPath: ".git/refs", withIntermediateDirectories: false)
- // fileManager.createFile(atPath: ".git/HEAD", contents: "ref: refs/heads/master\n".data(using: .utf8))
- //
- // print("Initialized git directory")
- // default:
- // print("Unknown command \(command)")
- // return
- // }
+ let command = CommandLine.arguments[1]
+ switch command {
+ case "init":
+ let fileManager = FileManager.default
+
+ try fileManager.createDirectory(atPath: ".git", withIntermediateDirectories: false)
+ try fileManager.createDirectory(atPath: ".git/objects", withIntermediateDirectories: false)
+ try fileManager.createDirectory(atPath: ".git/refs", withIntermediateDirectories: false)
+ fileManager.createFile(atPath: ".git/HEAD", contents: "ref: refs/heads/master\n".data(using: .utf8))
+
+ print("Initialized git directory")
+ default:
+ print("Unknown command \(command)")
+ return
+ }
}
}