├── .gitignore
├── Working
├── logo.png
└── logo.psd
├── BriskScript
├── Sources
│ ├── main.swift
│ └── Brisk
│ │ ├── Array.swift
│ │ ├── Comparable.swift
│ │ ├── Date.swift
│ │ ├── URL.swift
│ │ ├── Process.swift
│ │ ├── BinaryFloatingPoint.swift
│ │ ├── Encodable.swift
│ │ ├── Sequence.swift
│ │ ├── System.swift
│ │ ├── Numeric.swift
│ │ ├── Decodable.swift
│ │ ├── Data.swift
│ │ ├── Directory.swift
│ │ ├── XML.swift
│ │ ├── File.swift
│ │ └── String.swift
├── .swiftpm
│ └── xcode
│ │ └── package.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcuserdata
│ │ └── username.xcuserdatad
│ │ └── UserInterfaceState.xcuserstate
└── Package.swift
├── makefile
├── brisk.sh
├── LICENSE
├── CODE_OF_CONDUCT.md
└── README.md
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | /.build
3 | /Packages
4 | /*.xcodeproj
--------------------------------------------------------------------------------
/Working/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/twostraws/Brisk/HEAD/Working/logo.png
--------------------------------------------------------------------------------
/Working/logo.psd:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/twostraws/Brisk/HEAD/Working/logo.psd
--------------------------------------------------------------------------------
/BriskScript/Sources/main.swift:
--------------------------------------------------------------------------------
1 | import Foundation
2 |
3 | print("Hello, Brisk!")
4 |
--------------------------------------------------------------------------------
/BriskScript/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/BriskScript/Sources/Brisk/Array.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Array.swift
3 | // Terminal
4 | //
5 | // Created by Paul Hudson on 20/02/2020.
6 | // Copyright © 2020 Hacking with Swift. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | extension Array where Element: Equatable {
12 | mutating func remove(_ obj: Element) {
13 | self = self.filter { $0 != obj }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/BriskScript/Package.swift:
--------------------------------------------------------------------------------
1 | // swift-tools-version:5.1
2 | import PackageDescription
3 |
4 | let package = Package(
5 | name: "BriskScript",
6 | platforms: [
7 | .macOS(.v10_15)
8 | ],
9 | dependencies: [
10 | // .package(url: /* package url */, from: "1.0.0"),
11 | ],
12 | targets: [
13 | .target(name: "BriskScript", dependencies: [], path: "." )
14 | ]
15 | )
16 |
--------------------------------------------------------------------------------
/BriskScript/Sources/Brisk/Comparable.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Comparable.swift
3 | // Terminal
4 | //
5 | // Created by Paul Hudson on 20/02/2020.
6 | // Copyright © 2020 Hacking with Swift. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | extension Comparable {
12 | func clamp(low: Self, high: Self) -> Self {
13 | if self > high {
14 | return high
15 | } else if self < low {
16 | return low
17 | }
18 |
19 | return self
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/BriskScript/Sources/Brisk/Date.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Date.swift
3 | // Terminal
4 | //
5 | // Created by Paul Hudson on 20/02/2020.
6 | // Copyright © 2020 Hacking with Swift. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | extension Date {
12 | static func unixTime() -> Int {
13 | Int(Date().timeIntervalSince1970)
14 | }
15 |
16 | func string(using format: String) -> String {
17 | let dateFormatter = DateFormatter()
18 | dateFormatter.dateFormat = format
19 | return dateFormatter.string(from: Date())
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/BriskScript/Sources/Brisk/URL.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Comparable.swift
3 | // Terminal
4 | //
5 | // Created by Paul Hudson on 20/02/2020.
6 | // Copyright © 2020 Hacking with Swift. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | extension URL {
12 | /**
13 | Create new URLs by appending strings
14 | - Parameter lhs: The base URL to use
15 | - Parameter rhs: The string to append
16 | - Returns: A new URL combining the two
17 | */
18 | static func +(lhs: URL, rhs: String) -> URL {
19 | return lhs.appendingPathComponent(rhs)
20 | }
21 |
22 | static func +=(lhs: inout URL, rhs: String) {
23 | lhs.appendPathComponent(rhs)
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/BriskScript/Sources/Brisk/Process.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Process.swift
3 | // Terminal
4 | //
5 | // Created by Paul Hudson on 20/02/2020.
6 | // Copyright © 2020 Hacking with Swift. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | func getpid() -> Int {
12 | Int(ProcessInfo.processInfo.processIdentifier)
13 | }
14 |
15 | func getHostName() -> String {
16 | ProcessInfo.processInfo.hostName
17 | }
18 |
19 | func getUserName() -> String {
20 | ProcessInfo.processInfo.userName
21 | }
22 |
23 | func getenv(_ key: String) -> String {
24 | ProcessInfo.processInfo.environment[key, default: ""]
25 | }
26 |
27 | func setenv(_ key: String, _ value: String) {
28 | setenv(key, value, 1)
29 | }
30 |
--------------------------------------------------------------------------------
/makefile:
--------------------------------------------------------------------------------
1 | install:
2 | @# Flush out any existing Brisk template
3 | @rm -rf ~/.brisk
4 |
5 | @# Prepare to park our template in the hidden folder
6 | @mkdir ~/.brisk
7 |
8 | @# Copy our entire template into the hidden folder
9 | @cp -R BriskScript ~/.brisk/BriskScript
10 |
11 | @# Place our script creator in a sensible place
12 | @install brisk.sh /usr/local/bin/brisk
13 |
14 | @# Make it executable, so they can run "brisk fizz"
15 | @chmod u+x /usr/local/bin/brisk
16 |
17 | @echo "Installation complete!"
18 | @echo "You can now run \"brisk example\" to make a new script."
19 |
20 | uninstall:
21 | @# Remove any existing Brisk template
22 | @rm -rf ~/.brisk
23 |
24 | @# Remove our script creator
25 | @rm -rf /usr/local/bin/brisk
26 |
27 | @echo "Uninstall complete."
--------------------------------------------------------------------------------
/brisk.sh:
--------------------------------------------------------------------------------
1 | # Ensure they provide a script name
2 | if [ $# -ne 1 ]
3 | then
4 | echo "Usage: brisk