Skip to content

Commit

Permalink
Convert CLI command
Browse files Browse the repository at this point in the history
  • Loading branch information
alin23 committed Dec 20, 2023
1 parent 4b40237 commit d832705
Show file tree
Hide file tree
Showing 10 changed files with 235 additions and 35 deletions.
32 changes: 16 additions & 16 deletions Clop.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 2.5.0;
CURRENT_PROJECT_VERSION = 2.5.1;
DEVELOPMENT_TEAM = RDDXV84A73;
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
Expand All @@ -898,7 +898,7 @@
);
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
MACOSX_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = 2.5.0;
MARKETING_VERSION = 2.5.1;
PRODUCT_BUNDLE_IDENTIFIER = com.lowtechguys.Clop.FinderOptimiser;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand All @@ -917,7 +917,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 2.5.0;
CURRENT_PROJECT_VERSION = 2.5.1;
DEVELOPMENT_TEAM = RDDXV84A73;
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
Expand All @@ -933,7 +933,7 @@
);
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
MACOSX_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = 2.5.0;
MARKETING_VERSION = 2.5.1;
PRODUCT_BUNDLE_IDENTIFIER = com.lowtechguys.Clop.FinderOptimiser;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand All @@ -952,7 +952,7 @@
CODE_SIGN_ENTITLEMENTS = Setapp/Setapp.entitlements;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 2.5.0;
CURRENT_PROJECT_VERSION = 2.5.1;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "\"Clop/Preview Content\"";
DEVELOPMENT_TEAM = RDDXV84A73;
Expand All @@ -974,7 +974,7 @@
);
LLVM_LTO = YES_THIN;
MACOSX_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = 2.5.0;
MARKETING_VERSION = 2.5.1;
OTHER_LDFLAGS = (
"-force_load",
"$(BUILT_PRODUCTS_DIR)/libSetapp.a",
Expand All @@ -996,7 +996,7 @@
CODE_SIGN_ENTITLEMENTS = Setapp/Setapp.entitlements;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 2.5.0;
CURRENT_PROJECT_VERSION = 2.5.1;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "\"Clop/Preview Content\"";
DEVELOPMENT_TEAM = RDDXV84A73;
Expand All @@ -1018,7 +1018,7 @@
);
LLVM_LTO = YES;
MACOSX_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = 2.5.0;
MARKETING_VERSION = 2.5.1;
OTHER_LDFLAGS = (
"-force_load",
"$(BUILT_PRODUCTS_DIR)/libSetapp.a",
Expand All @@ -1038,7 +1038,7 @@
CODE_SIGN_ENTITLEMENTS = "Setapp/FinderOptimiser-setapp.entitlements";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 2.5.0;
CURRENT_PROJECT_VERSION = 2.5.1;
DEVELOPMENT_TEAM = RDDXV84A73;
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
Expand All @@ -1053,7 +1053,7 @@
);
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
MACOSX_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = 2.5.0;
MARKETING_VERSION = 2.5.1;
PRODUCT_BUNDLE_IDENTIFIER = "com.lowtechguys.Clop-setapp.FinderOptimiser";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
Expand All @@ -1070,7 +1070,7 @@
CODE_SIGN_ENTITLEMENTS = "Setapp/FinderOptimiser-setapp.entitlements";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 2.5.0;
CURRENT_PROJECT_VERSION = 2.5.1;
DEVELOPMENT_TEAM = RDDXV84A73;
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
Expand All @@ -1085,7 +1085,7 @@
);
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
MACOSX_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = 2.5.0;
MARKETING_VERSION = 2.5.1;
PRODUCT_BUNDLE_IDENTIFIER = "com.lowtechguys.Clop-setapp.FinderOptimiser";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
Expand Down Expand Up @@ -1321,7 +1321,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 2.5.0;
CURRENT_PROJECT_VERSION = 2.5.1;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "\"Clop/Preview Content\"";
DEVELOPMENT_TEAM = RDDXV84A73;
Expand All @@ -1342,7 +1342,7 @@
);
LLVM_LTO = YES_THIN;
MACOSX_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = 2.5.0;
MARKETING_VERSION = 2.5.1;
PRODUCT_BUNDLE_IDENTIFIER = com.lowtechguys.Clop;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand All @@ -1361,7 +1361,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 2.5.0;
CURRENT_PROJECT_VERSION = 2.5.1;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "\"Clop/Preview Content\"";
DEVELOPMENT_TEAM = RDDXV84A73;
Expand All @@ -1382,7 +1382,7 @@
);
LLVM_LTO = YES;
MACOSX_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = 2.5.0;
MARKETING_VERSION = 2.5.1;
OTHER_LDFLAGS = "";
PRODUCT_BUNDLE_IDENTIFIER = com.lowtechguys.Clop;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>ClopCLI-setapp.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>3</integer>
<integer>4</integer>
</dict>
<key>ClopCLI.xcscheme_^#shared#^_</key>
<dict>
Expand Down Expand Up @@ -95,7 +95,7 @@
<key>FinderOptimiser-setapp.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>4</integer>
<integer>3</integer>
</dict>
<key>FinderOptimiser.xcscheme_^#shared#^_</key>
<dict>
Expand Down
2 changes: 1 addition & 1 deletion Clop/CherryPicks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ extension String {
}

var trimmedPath: String {
trimmingCharacters(in: ["\"", "'", "\n", "\t", " ", "(", ")", "[", "]", "{", "}", ","])
trimmingCharacters(in: ["\"", "'", "\n", "\t", " ", "{", "}", ","])
}
}

Expand Down
5 changes: 4 additions & 1 deletion Clop/ClopApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ class AppDelegate: AppDelegateParent {
trialText = "This is a trial for the Pro features. After the trial, the app will automatically revert to the free version."
price = 15
productName = "Clop Pro"
vendorName = "Panaitiu Alin Valentin PFA"
vendorName = "The low-tech guys"
hasFreeFeatures = true
#endif

Expand All @@ -454,6 +454,9 @@ class AppDelegate: AppDelegateParent {
#if !SETAPP
UM.updater = updateController.updater
PM.pro = pro
if !SWIFTUI_PREVIEW {
pro.checkProLicense()
}
#endif

NSApplication.shared.windows.first?.close()
Expand Down
2 changes: 1 addition & 1 deletion Clop/ClopShortcuts.swift
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ struct ConvertImageIntent: AppIntent {
}

var outFilePath: FilePath = if let outPath = output?.filePath, outPath.string.contains("/"), outPath.string.starts(with: "/") {
outPath.isDir ? outPath.appending(stem) : path.dir / generateFileName(template: outPath.name.string, for: path, autoIncrementingNumber: &Defaults[.lastAutoIncrementingNumber])
outPath.isDir ? outPath.appending(stem) : outPath.dir / generateFileName(template: outPath.name.string, for: path, autoIncrementingNumber: &Defaults[.lastAutoIncrementingNumber])
} else if let output {
path.dir / generateFileName(template: output, for: path, autoIncrementingNumber: &Defaults[.lastAutoIncrementingNumber])
} else {
Expand Down
10 changes: 8 additions & 2 deletions Clop/ClopUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -474,12 +474,18 @@ func unarchiveBinaries() {
}

let cliDir = GLOBAL_BIN_DIR_PARENT.deletingLastPathComponent().appendingPathComponent("ClopCLI")
if fm.fileExists(atPath: cliDir.path), (try? fm.destinationOfSymbolicLink(atPath: cliDir.path)) != GLOBAL_BIN_DIR_PARENT.path {
try! fm.removeItem(at: cliDir)
}
if !fm.fileExists(atPath: cliDir.path) {
try! fm.linkItem(at: GLOBAL_BIN_DIR_PARENT, to: cliDir)
try! fm.createSymbolicLink(at: cliDir, withDestinationURL: GLOBAL_BIN_DIR_PARENT)
}

let finderOptimiserDir = GLOBAL_BIN_DIR_PARENT.deletingLastPathComponent().appendingPathComponent("\(GLOBAL_BIN_DIR_PARENT.lastPathComponent).FinderOptimiser")
if fm.fileExists(atPath: finderOptimiserDir.path), (try? fm.destinationOfSymbolicLink(atPath: finderOptimiserDir.path)) != GLOBAL_BIN_DIR_PARENT.path {
try! fm.removeItem(at: finderOptimiserDir)
}
if !fm.fileExists(atPath: finderOptimiserDir.path) {
try! fm.linkItem(at: GLOBAL_BIN_DIR_PARENT, to: finderOptimiserDir)
try! fm.createSymbolicLink(at: finderOptimiserDir, withDestinationURL: GLOBAL_BIN_DIR_PARENT)
}
}
6 changes: 2 additions & 4 deletions Clop/Images.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ let PNGQUANT = BIN_DIR.appendingPathComponent("pngquant").existingFilePath!
let JPEGOPTIM = BIN_DIR.appendingPathComponent("jpegoptim").existingFilePath!
let GIFSICLE = BIN_DIR.appendingPathComponent("gifsicle").existingFilePath!
let VIPSTHUMBNAIL = BIN_DIR.appendingPathComponent("vipsthumbnail").existingFilePath!
let HEIF_ENC = BIN_DIR.appendingPathComponent("heif-enc").existingFilePath!
let CWEBP = BIN_DIR.appendingPathComponent("cwebp").existingFilePath!

extension NSPasteboard.PasteboardType {
static let jpeg = NSPasteboard.PasteboardType(rawValue: "public.jpeg")
Expand Down Expand Up @@ -335,7 +333,7 @@ class Image: CustomStringConvertible {
allowImage = true
}
guard allowImage, let nsImage = nsImage ?? NSImage(pasteboard: pb) ?? nsImageFromPath() else {
throw ClopError.noClipboardImage(item.filePath ?? .init())
throw ClopError.noClipboardImage(.init())
}

let optimised = item.string(forType: .optimisationStatus) == "true"
Expand All @@ -350,7 +348,7 @@ class Image: CustomStringConvertible {
}

guard let img = Image(nsImage: nsImage, data: data, optimised: optimised, retinaDownscaled: false) else {
throw ClopError.noClipboardImage(item.filePath ?? .init())
throw ClopError.noClipboardImage(.init())
}

return img
Expand Down
Loading

0 comments on commit d832705

Please sign in to comment.