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
Copy file name to clipboardExpand all lines: README.md
+30-14Lines changed: 30 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -57,31 +57,47 @@ And then import wherever needed: `import MintKit`
57
57
58
58
## Usage
59
59
60
-
Mint has 2 commands, `run` and `install`.
60
+
Run `mint` to see usage instructions.
61
61
62
-
#### Install
63
-
This will checkout, build and copy a specific build by git tag
62
+
```
63
+
$ mint
64
+
Usage:
65
+
mint [command]
66
+
67
+
Available Commands:
68
+
install Install a package
69
+
run Run a package
70
+
update Update a package
71
+
72
+
Use "mint [command] --help" for more information about a command.
73
+
```
64
74
65
-
#### Run
66
-
Run will run a certain tool from the package. If it's not installed, it will install it first
75
+
-**Install**: Installs a package. If it is already installed this won't do anything
76
+
-**Run**: Runs a package. This will install if first if it doesn't exist
77
+
-**Update**: Installs a package while enforcing an update and rebuild. Shouldn't be required unless you are pointing at a branch and want to update.
67
78
68
-
#### Options
79
+
These 3 commands use the same flags. They must all be followed by a repo name.
80
+
This can be a shorthand for a github repo `install realm/SwiftLint` or a fully qualified git path `install https://github.com/realm/SwiftLint.git`.
69
81
70
-
Each command is followed by git path, version and tool name. Anything after that in `run` will be passed to the command line tool.
82
+
##### Repo
83
+
In the case of `run` you can also just pass the name of the repo if it is already installed `run swiftlint`. This will do a lookup of all installed packages.
71
84
72
-
Git path can take the form:
85
+
#### Version
86
+
By default the version that is used is the latest git tag (or master if no tags exist). You can pass a specific version with the version flag (-v, --version) eg. `--version 1.2.0`
73
87
74
-
-`yonaskolb/xcodegen` (github repo name)
75
-
-`github.com/yonaskolb/xcodegen` (github repo)
76
-
-`http://github.com/yonaskolb/xcodegen.git` (any full git path)
88
+
#### Name
89
+
By default the tool name will be the last path in the repo (so for `realm/swiftlint` it will be `swiftlint`). If there are any packages that have a different executable name when build you can specify it with `--name`
77
90
78
-
The first 2 examples would be transformed into the last
91
+
#### Arguments
92
+
To pass in arguments to the final tool on `run` you need to use `--args="any arguments"`
79
93
94
+
#### Examples
80
95
```
81
-
$ mint run yonaskolb/xcodegen 1.2.0 xcodegen
96
+
$ mint install yonaskolb/xcodegen 1.2.0 --args="--spec my_spec.yml"
97
+
$ mint install yonaskolb/xcodegen
98
+
$ mint run xcodegen
82
99
```
83
100
84
-
85
101
## Package.resources
86
102
As the Swift Packager doesn't yet have a way of specifying resources directories, Mint looks for a custom `Package.resources` file in the repo. This is a plain text file that lists the resources directories on different lines:
Copy file name to clipboardExpand all lines: Sources/Mint/main.swift
+75-9Lines changed: 75 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -2,15 +2,81 @@ import MintKit
2
2
import Rainbow
3
3
import Foundation
4
4
import ShellOut
5
+
import Guaka
5
6
6
-
do{
7
-
tryMint.execute()
8
-
}catch{
9
-
iflet error = error as?ShellOutError{
10
-
letmessage="Error: \(error.message)".red
11
-
print("🌱 \(message)\n\(error.output)")
12
-
}else{
13
-
print("🌱 Error: \(error)".red)
7
+
func catchError(closure:()throws->()){
8
+
do{
9
+
tryclosure()
10
+
}catch{
11
+
iflet error = error as?ShellOutError{
12
+
if !error.message.isEmpty {
13
+
print(error.message.red)
14
+
}
15
+
if !error.output.isEmpty {
16
+
print(error.output)
17
+
}
18
+
}else{
19
+
print("🌱 Error: \(error)".red)
20
+
}
21
+
exit(1)
14
22
}
15
-
exit(1)
16
23
}
24
+
25
+
letcommand=Command(usage:"mint")
26
+
command.run ={ _, _ in
27
+
print(command.helpMessage)
28
+
}
29
+
30
+
letrepoHelp="You must pass a repo either in the shorthand for of a github repo \"githubName/repo\", or a fully qualified .git path.\nAn optional version can be passed, otherwise the newest tag or master will be used"
31
+
letversionFlag=Flag(shortName:"v", longName:"version", type:String.self, description:"The version to use. Usually this is a tag, but can also be a branch. If left out will use the latest tag or master")
32
+
33
+
letnameFlag=Flag(shortName:"n", longName:"name", type:String.self, description:"The command to run")
34
+
35
+
letargsFlag=Flag(shortName:"a", longName:"args", type:String.self, description:"the arguments to pass to the command being run")
36
+
37
+
letrunCommand=Command(usage:"run repo (version)", shortMessage:"Run a package", longMessage:"This will run a package tool. If it isn't installed if will do so first.\n\(repoHelp)", flags:[nameFlag, argsFlag], example:"mint run realm/swiftlint 0.22.0"){ flags, args in
letinstallCommand=Command(usage:"install repo (version)", shortMessage:"Install a package", longMessage:"This will install a package. If it's already installed no action will be taken.\n\(repoHelp)", flags:[nameFlag], example:"mint install realm/swiftlint 0.22.0"){ flags, args in
letupdateCommand=Command(usage:"update repo (version)", shortMessage:"Update a package", longMessage:"This will update a package even if it's already installed.\n\(repoHelp)", flags:[nameFlag], example:"mint install realm/swiftlint 0.22.0"){ flags, args in
0 commit comments