File tree 3 files changed +13
-2
lines changed 3 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ public enum OptionParserError: ErrorProtocol {
18
18
case expectedAssociatedValue( String )
19
19
case unexpectedAssociatedValue( String , String )
20
20
case invalidUsage( String )
21
+ case noCommandProvided( String )
21
22
}
22
23
23
24
extension OptionParserError : CustomStringConvertible {
@@ -33,6 +34,8 @@ extension OptionParserError: CustomStringConvertible {
33
34
return " unknown command: \( cmd) "
34
35
case . invalidUsage( let hint) :
35
36
return " invalid usage: \( hint) "
37
+ case . noCommandProvided( let hint) :
38
+ return " no command provided: \( hint) "
36
39
}
37
40
}
38
41
}
Original file line number Diff line number Diff line change @@ -53,10 +53,17 @@ extension Error: CustomStringConvertible {
53
53
print ( " " , to: & stderr)
54
54
usage { print ( $0, to: & stderr) }
55
55
}
56
+ case OptionParserError . noCommandProvided( let hint) :
57
+ if !hint. isEmpty {
58
+ print ( error: error)
59
+ }
60
+ if isTTY ( . stdErr) {
61
+ usage { print ( $0, to: & stderr) }
62
+ }
56
63
case is OptionParserError :
57
64
print ( error: error)
58
65
if isTTY ( . stdErr) {
59
- let argv0 = Process . arguments. first ?? " swift build "
66
+ let argv0 = Process . arguments. first ?? " swift package "
60
67
print ( " enter ` \( argv0) --help' for usage information " , to: & stderr)
61
68
}
62
69
default :
Original file line number Diff line number Diff line change @@ -287,7 +287,8 @@ public struct SwiftPackageTool {
287
287
return ( mode, opts)
288
288
}
289
289
else {
290
- throw OptionParserError . invalidUsage ( " no command provided: \( args) " )
290
+ // FIXME: This needs to produce a properly quoted string, once we have such API.
291
+ throw OptionParserError . noCommandProvided ( args. joined ( separator: " " ) )
291
292
}
292
293
}
293
294
}
You can’t perform that action at this time.
0 commit comments