Skip to content
This repository was archived by the owner on Jul 4, 2020. It is now read-only.

Commit fb7b866

Browse files
committed
Clean up and moved actions to the framework
1 parent b9f706c commit fb7b866

File tree

7 files changed

+53
-37
lines changed

7 files changed

+53
-37
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import Foundation
2+
3+
public func getCurrentSong() -> ActionWithOutput {
4+
return Action(identifier: "is.workflow.actions.getcurrentsong", parameters: [:])
5+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import Foundation
2+
3+
public func getText(_ text: String) -> ActionWithOutput {
4+
return Action(
5+
identifier: "is.workflow.actions.gettext",
6+
parameters: ["WFTextActionText": withInterpolatedText(text)]
7+
)
8+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import Foundation
2+
3+
public func tweet(showComposeSheet: Bool = true) -> Action {
4+
return Action(
5+
identifier: "is.workflow.actions.tweet",
6+
parameters: [
7+
"WFSocialActionShowComposeSheet": showComposeSheet,
8+
]
9+
)
10+
}

ShortcutsSwift.playgroundbook/Contents/Sources/InterpolatedText.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Foundation
22

3-
public func withInterpolatedText(_ string: String) -> Any {
3+
func withInterpolatedText(_ string: String) -> Any {
44
var result = string
55
var attachments = [String: Any]()
66

ShortcutsSwift.xcodeproj/project.pbxproj

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@
3838
98D33C2B21D3E34100824660 /* Repeat.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98D33C2A21D3E34100824660 /* Repeat.swift */; };
3939
98D33C3021D3EFF100824660 /* Calculate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98D33C2F21D3EFF100824660 /* Calculate.swift */; };
4040
98D33C3421D4067C00824660 /* List.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98D33C3321D4067C00824660 /* List.swift */; };
41+
FB651C2721DE29D20029DAE6 /* Twitter.swift in Sources */ = {isa = PBXBuildFile; fileRef = FB651C2621DE29D20029DAE6 /* Twitter.swift */; };
42+
FB651C2921DE2A810029DAE6 /* GetText.swift in Sources */ = {isa = PBXBuildFile; fileRef = FB651C2821DE2A810029DAE6 /* GetText.swift */; };
43+
FB651C2B21DE2AAF0029DAE6 /* GetCurrentSong.swift in Sources */ = {isa = PBXBuildFile; fileRef = FB651C2A21DE2AAF0029DAE6 /* GetCurrentSong.swift */; };
4144
FBDA8D4321DCCA9E00303374 /* AggrandizementTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FBDA8D4221DCCA9E00303374 /* AggrandizementTests.swift */; };
4245
/* End PBXBuildFile section */
4346

@@ -85,6 +88,9 @@
8588
98D33C2A21D3E34100824660 /* Repeat.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Repeat.swift; sourceTree = "<group>"; };
8689
98D33C2F21D3EFF100824660 /* Calculate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Calculate.swift; sourceTree = "<group>"; };
8790
98D33C3321D4067C00824660 /* List.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = List.swift; sourceTree = "<group>"; };
91+
FB651C2621DE29D20029DAE6 /* Twitter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Twitter.swift; sourceTree = "<group>"; };
92+
FB651C2821DE2A810029DAE6 /* GetText.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GetText.swift; sourceTree = "<group>"; };
93+
FB651C2A21DE2AAF0029DAE6 /* GetCurrentSong.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GetCurrentSong.swift; sourceTree = "<group>"; };
8894
FBDA8D4221DCCA9E00303374 /* AggrandizementTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AggrandizementTests.swift; sourceTree = "<group>"; };
8995
FB7EE87321DC326B00C079C7 /* ShortcutsSwiftXcode.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = ShortcutsSwiftXcode.playground; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
9096
/* End PBXFileReference section */
@@ -186,6 +192,9 @@
186192
5502FFD021D0F1A400CE7544 /* Share.swift */,
187193
5502FFD121D0F1A400CE7544 /* ShowResult.swift */,
188194
98D33C2821D3DA0A00824660 /* SplitText.swift */,
195+
FB651C2821DE2A810029DAE6 /* GetText.swift */,
196+
FB651C2A21DE2AAF0029DAE6 /* GetCurrentSong.swift */,
197+
FB651C2621DE29D20029DAE6 /* Twitter.swift */,
189198
);
190199
path = Actions;
191200
sourceTree = "<group>";
@@ -334,11 +343,14 @@
334343
5502FFEC21D0F29700CE7544 /* PlaygroundSupport.swift in Sources */,
335344
5502FFEA21D0F1A400CE7544 /* Action.swift in Sources */,
336345
83F8639821D15F7E00925583 /* Dictionary.swift in Sources */,
346+
FB651C2921DE2A810029DAE6 /* GetText.swift in Sources */,
337347
98D33C3421D4067C00824660 /* List.swift in Sources */,
338348
98D33C2B21D3E34100824660 /* Repeat.swift in Sources */,
349+
FB651C2721DE29D20029DAE6 /* Twitter.swift in Sources */,
339350
5502FFE421D0F1A400CE7544 /* Share.swift in Sources */,
340351
98D33C2921D3DA0A00824660 /* SplitText.swift in Sources */,
341352
5502FFDD21D0F1A400CE7544 /* CopyToClipboard.swift in Sources */,
353+
FB651C2B21DE2AAF0029DAE6 /* GetCurrentSong.swift in Sources */,
342354
5502FFDF21D0F1A400CE7544 /* Comment.swift in Sources */,
343355
5502FFE321D0F1A400CE7544 /* ChooseFromMenu.swift in Sources */,
344356
5502FFD721D0F1A400CE7544 /* ShortcutShareViewController.swift in Sources */,

ShortcutsSwiftXcode.playground/Contents.swift

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,6 @@
11

22
import ShortcutsSwift
33

4-
import Foundation
5-
import PlaygroundSupport
6-
public func saveShortcut(_ shortcut: PropertyList, name: String) {
7-
let data = exportShortcut(shortcut)
8-
func save(ext: String) {
9-
let fileURL = URL(fileURLWithPath: "")
10-
.appendingPathComponent(name)
11-
.appendingPathExtension(ext)
12-
try! data.write(to: fileURL)
13-
print("open \(fileURL.deletingLastPathComponent().absoluteString.dropFirst(7))")
14-
}
15-
save(ext: "shortcut")
16-
// TESTING
17-
save(ext: "plist")
18-
}
19-
20-
public func getCurrentSong() -> ActionWithOutput {
21-
return Action(identifier: "is.workflow.actions.getcurrentsong", parameters: [:])
22-
}
23-
24-
public func getText(_ text: String) -> ActionWithOutput {
25-
return Action(
26-
identifier: "is.workflow.actions.gettext",
27-
parameters: ["WFTextActionText": withInterpolatedText(text)]
28-
)
29-
}
30-
31-
public func tweet(showComposeSheet: Bool = true) -> Action {
32-
return Action(
33-
identifier: "is.workflow.actions.tweet",
34-
parameters: [
35-
"WFSocialActionShowComposeSheet": showComposeSheet,
36-
]
37-
)
38-
}
39-
404
let song = actionOutput()
415
let title = song.with(propertyName: .custom("Title"), userInfo: .string("title"))
426
let artist = song.with(propertyName: .custom("Artist"), userInfo: .string("artist"))
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import ShortcutsSwift
2+
import Foundation
3+
import PlaygroundSupport
4+
5+
public func saveShortcut(_ shortcut: PropertyList, name: String) {
6+
let data = exportShortcut(shortcut)
7+
func save(ext: String) {
8+
let fileURL = URL(fileURLWithPath: "")
9+
.appendingPathComponent(name)
10+
.appendingPathExtension(ext)
11+
try! data.write(to: fileURL)
12+
print("open \(fileURL.deletingLastPathComponent().absoluteString.dropFirst(7))")
13+
}
14+
save(ext: "shortcut")
15+
// TESTING
16+
save(ext: "plist")
17+
}

0 commit comments

Comments
 (0)