Skip to content

Commit

Permalink
Create command (sorta)
Browse files Browse the repository at this point in the history
  • Loading branch information
IsaacMarovitz committed Sep 26, 2023
1 parent f023e0c commit b254395
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
8 changes: 8 additions & 0 deletions Whisky.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
6E50D98329CD6066008C39F6 /* BottleVM.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E50D98229CD6066008C39F6 /* BottleVM.swift */; };
6E50D98529CDF25B008C39F6 /* BottleCreationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E50D98429CDF25B008C39F6 /* BottleCreationView.swift */; };
6E59676B2A9A424900D64F70 /* ArgumentParser in Frameworks */ = {isa = PBXBuildFile; productRef = 6E59676A2A9A424900D64F70 /* ArgumentParser */; };
6E5B61B62AC34E6D007B1913 /* SemanticVersion in Frameworks */ = {isa = PBXBuildFile; productRef = 6E5B61B52AC34E6D007B1913 /* SemanticVersion */; };
6E621CEF2A5F631300C9AAB3 /* Winetricks.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E621CEE2A5F631200C9AAB3 /* Winetricks.swift */; };
6E6915452A3265BB0085BBB7 /* Logger.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E6915442A3265BB0085BBB7 /* Logger.swift */; };
6E6C0CF22A419A6800356232 /* WelcomeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E6C0CF12A419A6800356232 /* WelcomeView.swift */; };
Expand Down Expand Up @@ -241,6 +242,7 @@
files = (
6EDF9AB72A9A6E50006CAA7E /* WhiskyKit.framework in Frameworks */,
6E95F6732AB3F67200D585D1 /* Progress in Frameworks */,
6E5B61B62AC34E6D007B1913 /* SemanticVersion in Frameworks */,
6E95F6702AB3F33C00D585D1 /* SwiftyTextTable in Frameworks */,
6E59676B2A9A424900D64F70 /* ArgumentParser in Frameworks */,
);
Expand Down Expand Up @@ -524,6 +526,7 @@
6E59676A2A9A424900D64F70 /* ArgumentParser */,
6E95F66F2AB3F33C00D585D1 /* SwiftyTextTable */,
6E95F6722AB3F67200D585D1 /* Progress */,
6E5B61B52AC34E6D007B1913 /* SemanticVersion */,
);
productName = WhiskyCmd;
productReference = 6E70A4982A9A2197007799E9 /* WhiskyCmd */;
Expand Down Expand Up @@ -1344,6 +1347,11 @@
package = 6E5967682A9A421800D64F70 /* XCRemoteSwiftPackageReference "swift-argument-parser" */;
productName = ArgumentParser;
};
6E5B61B52AC34E6D007B1913 /* SemanticVersion */ = {
isa = XCSwiftPackageProductDependency;
package = EB58FB532A499896002DC184 /* XCRemoteSwiftPackageReference "SemanticVersion" */;
productName = SemanticVersion;
};
6E95F66F2AB3F33C00D585D1 /* SwiftyTextTable */ = {
isa = XCSwiftPackageProductDependency;
package = 6E95F66E2AB3F33C00D585D1 /* XCRemoteSwiftPackageReference "SwiftyTextTable" */;
Expand Down
22 changes: 20 additions & 2 deletions WhiskyCmd/Main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import ArgumentParser
import WhiskyKit
import SwiftyTextTable
import Progress
import SemanticVersion

@main
struct Whisky: ParsableCommand {
Expand Down Expand Up @@ -52,10 +53,27 @@ extension Whisky {
static var configuration = CommandConfiguration(abstract: "Create a new bottle.")

@Argument var name: String
@Argument var path: String?

mutating func run() throws {
print("Create a bottle")
let bottleURL = BottleData.defaultBottleDir.appending(path: UUID().uuidString)

do {
try FileManager.default.createDirectory(atPath: bottleURL.path(percentEncoded: false),
withIntermediateDirectories: true)
let bottle = Bottle(bottleUrl: bottleURL, inFlight: true)
// Should allow customisation
bottle.settings.windowsVersion = .win10
bottle.settings.name = name
// try await Wine.changeWinVersion(bottle: bottle, win: winVersion)
// let wineVer = try await Wine.wineVersion()
bottle.settings.wineVersion = SemanticVersion(0, 0, 0)

var bottlesList = BottleData()
bottlesList.paths.append(bottleURL)
print("Created new bottle \"\(name)\".")
} catch {
print(error)
}
}
}

Expand Down

0 comments on commit b254395

Please sign in to comment.