You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Make for the `--unmanaged` flag on `add` to have an optional argument of
a commit or a branch. However this lead to complications around other
flags being passed such as `add blah --unmanaged -u -v`.
To resolve that issue, the properties on `Option` were move to `public`
so the add command could try its best to still apply arguments when
they were inadvertantly swallowed by the now `--unmanaged` optional
value.
Also the `unmanagedValue` is tracked in the `.modulo` file like `branch`
was but is more generic supporting an entire commit hash or a branch
name
Copy file name to clipboardExpand all lines: ModuloKit/Commands/AddCommand.swift
+20-11
Original file line number
Diff line number
Diff line change
@@ -16,10 +16,10 @@ import Foundation
16
16
openclassAddCommand:NSObject,Command{
17
17
// internal properties
18
18
fileprivatevarversion:SemverRange?=nil
19
-
fileprivatevarbranch:String?=nil
20
19
fileprivatevarrepositoryURL:String!=nil
21
20
fileprivatevarshouldUpdate:Bool=false
22
21
fileprivatevarunmanaged:Bool=false
22
+
fileprivatevarunmanagedValue:String?=nil
23
23
24
24
// Protocol conformance
25
25
openvarname:String{return"add"}
@@ -41,15 +41,24 @@ open class AddCommand: NSObject, Command {
41
41
self.version =SemverRange(value)
42
42
}
43
43
}
44
-
45
-
addOptionValue(["--branch"], usage:"specify the branch to track", valueSignature:"<branch>"){(option, value)in
46
-
iflet value = value {
47
-
self.branch = value
48
-
}
49
-
}
50
44
51
-
addOption(["--unmanaged"], usage:"specifies that this module will be unmanaged"){(option, value)in
45
+
addOptionValue(["--unmanaged"], usage:"specifies that this module will be unmanaged", valueSignature:"<[hash|branch|nothing]>"){(option, value)->Voidin
52
46
self.unmanaged =true
47
+
iflet value = value {
48
+
if !value.hasPrefix("-"){
49
+
self.unmanagedValue = value
50
+
}else{
51
+
ifself.verbose {
52
+
writeln(.stderr,"Assuming '\(value)' is a flag and not a branch/commit hash since it begins with '-' and will not track it.")
53
+
}
54
+
// TODO: Somehow reprocess this `value` as a flag
55
+
self.options.filter({(option)->Boolin
56
+
option.flags?.contains(value)??false
57
+
}).forEach({(option)in
58
+
option.closure(value,nil)
59
+
})
60
+
}
61
+
}
53
62
}
54
63
55
64
addOption(["-u","--update"], usage:"performs the update command after adding a module"){(option, value)in
@@ -64,8 +73,8 @@ open class AddCommand: NSObject, Command {
0 commit comments