Skip to content

Commit

Permalink
support more files
Browse files Browse the repository at this point in the history
  • Loading branch information
underthestars-zhy committed Jul 13, 2023
1 parent ff820fd commit 7f4459d
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 37 deletions.
4 changes: 0 additions & 4 deletions SwiftGGFormatter.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
/* Begin PBXBuildFile section */
90B11FF32A2B8CDA00188D29 /* SwiftGGFormatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 90B11FF22A2B8CDA00188D29 /* SwiftGGFormatter.swift */; };
90B11FFB2A2B8CFA00188D29 /* SwiftGGFormater in Frameworks */ = {isa = PBXBuildFile; productRef = 90B11FFA2A2B8CFA00188D29 /* SwiftGGFormater */; };
90B11FFD2A2B8D0600188D29 /* Mapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 90B11FFC2A2B8D0600188D29 /* Mapper.swift */; };
90B120002A2B8EB200188D29 /* ArgumentParser in Frameworks */ = {isa = PBXBuildFile; productRef = 90B11FFF2A2B8EB200188D29 /* ArgumentParser */; };
/* End PBXBuildFile section */

Expand All @@ -28,7 +27,6 @@
/* Begin PBXFileReference section */
90B11FEF2A2B8CDA00188D29 /* SwiftGGFormatter */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = SwiftGGFormatter; sourceTree = BUILT_PRODUCTS_DIR; };
90B11FF22A2B8CDA00188D29 /* SwiftGGFormatter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftGGFormatter.swift; sourceTree = "<group>"; };
90B11FFC2A2B8D0600188D29 /* Mapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Mapper.swift; sourceTree = "<group>"; };
90B120012A2B903F00188D29 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
/* End PBXFileReference section */

Expand Down Expand Up @@ -66,7 +64,6 @@
isa = PBXGroup;
children = (
90B11FF22A2B8CDA00188D29 /* SwiftGGFormatter.swift */,
90B11FFC2A2B8D0600188D29 /* Mapper.swift */,
);
path = SwiftGGFormatter;
sourceTree = "<group>";
Expand Down Expand Up @@ -137,7 +134,6 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
90B11FFD2A2B8D0600188D29 /* Mapper.swift in Sources */,
90B11FF32A2B8CDA00188D29 /* SwiftGGFormatter.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"pins" : [
{
"identity" : "swift-argument-parser",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-argument-parser.git",
"state" : {
"revision" : "fee6933f37fde9a5e12a1e4aeaa93fe60116ff2a",
"version" : "1.2.2"
}
},
{
"identity" : "swiftggformater",
"kind" : "remoteSourceControl",
"location" : "https://github.com/underthestars-zhy/SwiftGGFormater",
"state" : {
"revision" : "02e38eac9d441e74d8e394c910968c39ee193454",
"version" : "1.0.0"
}
},
{
"identity" : "swiftsoup",
"kind" : "remoteSourceControl",
"location" : "https://github.com/scinfu/SwiftSoup",
"state" : {
"revision" : "0e96a20ffd37a515c5c963952d4335c89bed50a6",
"version" : "2.6.0"
}
},
{
"identity" : "yams",
"kind" : "remoteSourceControl",
"location" : "https://github.com/jpsim/Yams.git",
"state" : {
"revision" : "f47ba4838c30dbd59998a4e4c87ab620ff959e8a",
"version" : "5.0.5"
}
}
],
"version" : 2
}
32 changes: 0 additions & 32 deletions SwiftGGFormatter/Mapper.swift

This file was deleted.

10 changes: 9 additions & 1 deletion SwiftGGFormatter/SwiftGGFormatter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,15 @@ struct SwiftGGFormatterCLI: AsyncParsableCommand {

mutating func run() async throws {
let file = URL.init(filePath: path)
let formater = SwiftGGFormater(file: file, web: URL(string: mapper[file.lastPathComponent]!)!)
let formater = SwiftGGFormater(file: file, web: findURL(path: path))
try await formater.formate()
}

func findURL(path: String) -> URL {
let file = URL.init(filePath: path)
let components = file.pathComponents
let category = components[components.endIndex - 2]
let fileName = file.deletingPathExtension().lastPathComponent
return URL(string: "https://developer.apple.com/tutorials/\(category)/\(fileName)")!
}
}

0 comments on commit 7f4459d

Please sign in to comment.