This repository was archived by the owner on Dec 29, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +29
-9
lines changed Expand file tree Collapse file tree 3 files changed +29
-9
lines changed Original file line number Diff line number Diff line change @@ -78,6 +78,12 @@ If you wish to specify a name for the Playground run:
78
78
$ swiftplayground new MyAwesomePlayground
79
79
```
80
80
81
+ Generate a Playground from your clipboard content via:
82
+
83
+ ``` bash
84
+ $ swiftplayground new --clipboard
85
+ ```
86
+
81
87
To generate a Playground with a SwiftUI template run:
82
88
83
89
``` bash
@@ -98,16 +104,18 @@ $ swiftplayground new --url https://gist.github.com/SvenTiigi/7eae5e55edd9be4121
98
104
<img src =" https://raw.githubusercontent.com/SvenTiigi/SwiftPlaygroundsCLI/gh-pages/readme-assets/RemoteOptionDemo.png " alt =" Remote Option Demo " >
99
105
</p >
100
106
101
-
102
107
## Arguments
103
108
104
109
A list of the available arguments that are supported by the SwiftPlaygroundsCLI.
105
110
111
+ ### new command
112
+
106
113
| Long parameter | Short parameter | Description
107
114
| ----------- | ----------- | -------------- |
108
- | ` --view ` | ` -v ` | Generate a Playground with a SwiftUI template |
109
- | ` --url ` | ` -u ` | Generate a Playground with contents from a URL |
115
+ | ` --clipboard ` | ` -c ` | Generate a Playground from the current Clipboard content |
110
116
| ` --silent ` | ` -s ` | Generate a Playground without opening the Playgrounds application |
117
+ | ` --url ` | ` -u ` | Generate a Playground with contents from a URL |
118
+ | ` --view ` | ` -v ` | Generate a Playground with a SwiftUI template |
111
119
112
120
## Contributing
113
121
Contributions are very welcome 🙌 🤓
Original file line number Diff line number Diff line change @@ -24,6 +24,10 @@ extension SwiftPlaygroundsCLI {
24
24
@Flag ( " -v " , " --view " , description: " Generate a Playground with a SwiftUI template " )
25
25
var viewContent : Bool
26
26
27
+ /// Bool value if Clipboard Content should be used
28
+ @Flag ( " -c " , " --clipboard " , description: " Generate a Playground from the current Clipboard content " )
29
+ var clipboardContent : Bool
30
+
27
31
/// The remote URL Content Key
28
32
@Key ( " -u " , " --url " , description: " Generate a Playground with contents from a URL " )
29
33
var remoteContentURL : String ?
@@ -65,6 +69,9 @@ extension SwiftPlaygroundsCLI.NewCommand: Command {
65
69
if self . viewContent {
66
70
// Set View Content
67
71
content = . view
72
+ } else if self . clipboardContent {
73
+ // Use Clipboard Content
74
+ content = . clipboard
68
75
} else if let remoteContentURL = self . remoteContentURL {
69
76
// If a remote content URL is available use remote
70
77
content = . remote( url: remoteContentURL)
Original file line number Diff line number Diff line change 5
5
// Created by Sven Tiigi on 12.02.20.
6
6
//
7
7
8
+ import Cocoa
8
9
import Foundation
9
10
10
11
// MARK: - Content
@@ -17,6 +18,8 @@ public extension PlaygroundBook {
17
18
case `default`
18
19
/// View Content
19
20
case view
21
+ /// Clipboard Content
22
+ case clipboard
20
23
/// Remove Content from URL
21
24
case remote( url: String )
22
25
}
@@ -36,12 +39,6 @@ extension PlaygroundBook.Content {
36
39
37
40
print( " Hello Developer " )
38
41
"""
39
- case . remote( let url) :
40
- if let code = self . loadCode ( from: url) {
41
- return code
42
- } else {
43
- return " // Unable to load content from: \( url) "
44
- }
45
42
case . view:
46
43
return """
47
44
import PlaygroundSupport
@@ -59,6 +56,14 @@ extension PlaygroundBook.Content {
59
56
let view = MyView()
60
57
PlaygroundPage.current.setLiveView(view)
61
58
"""
59
+ case . clipboard:
60
+ return NSPasteboard . general. string ( forType: . string) ?? . init( )
61
+ case . remote( let url) :
62
+ if let code = self . loadCode ( from: url) {
63
+ return code
64
+ } else {
65
+ return " // Unable to load content from: \( url) "
66
+ }
62
67
}
63
68
}
64
69
You can’t perform that action at this time.
0 commit comments