-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Updated to Lux 0.3.5 to fix Json escaped quotes - Moved explanations and examples in the doc command - Added colors to the documentation
- Loading branch information
Showing
19 changed files
with
561 additions
and
341 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import ArgumentParser | ||
import Lux | ||
|
||
struct AddDocumentation: Documentation { | ||
private static let jsonInjector = JSONInjector(type: .terminal) | ||
private static let zshInjector = ZshInjector(type: .terminal) | ||
|
||
private static let jsonExample = | ||
""" | ||
{ | ||
"people": { | ||
"Tom": { | ||
"height": 175, | ||
"age": 68, | ||
"hobbies": [ | ||
"cooking", | ||
"guitar" | ||
] | ||
}, | ||
"Arnaud": { | ||
"height": 180, | ||
"age": 23, | ||
"hobbies": [ | ||
"video games", | ||
"party", | ||
"tennis" | ||
] | ||
} | ||
} | ||
} | ||
""" | ||
|
||
private static let examples = [(#"`scout add "people.Franklin.height=165"`"#, #"will create a new dictionary Franklin and add a height key into it with the value 165"#), | ||
(#"`scout add "people.Tom.hobbies[-1]"="Playing music"`"#, #"will add the hobby "Playing music" to Tom hobbies at the end of the array"#), | ||
(#"`scout add "people.Arnaud.hobbies[1]=reading"`"#, #"will insert the hobby "reading" to Arnaud hobbies between the hobby "video games" and "party""#), | ||
(#"`scout add "people.Franklin.hobbies[0]"=football`"#, """ | ||
will create a new dictionary Franklin, | ||
add a hobbies array into it, and insert the value "football" in the array | ||
"""), | ||
(#"`scout add "people.Franklin.height=/165/"`"#, #"will create a new dictionary Franklin and add a height key into it with the String value "165""#), | ||
(#"`scout add "people.Franklin.height=~165~"`"#, #"will create a new dictionary Franklin and add a height key into it with the Real value 165 (Plist only)"#)] | ||
|
||
static let text = | ||
""" | ||
Add command | ||
============ | ||
Notes | ||
----- | ||
- You add delete multiple values in one command | ||
- Specify the \(zshInjector.delegate.inject(.optionNameOrFlag, in: .terminal, "-v")) flag to see the modified data | ||
- All the keys which do not exist in the path will be created | ||
- Enclose the value with slash signs to force the value as a string: /valueAsString/ (Plist, Json) | ||
- Enclose the value with interrogative signs to force the value as a boolean: ?valueToBoolean? (Plist, Json) | ||
- Enclose the value with tilde signs to force the value as a real: ~valueToReal~ (Plist) | ||
- Enclose the value with chevron signs to force the value as a integer: <valueToInteger> (Plist) | ||
- When adding an element in an array, use the index -1 to add the element at the end of the array | ||
Examples | ||
-------- | ||
JSON file | ||
\(jsonInjector.inject(in: jsonExample)) | ||
\(examplesText(from: examples)) | ||
""" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,29 @@ | ||
struct JsonColors: Codable { | ||
var punctuation: Int? | ||
var keyName: Int? | ||
var keyValue: Int? | ||
var punctuation: Int? = nil | ||
var keyName: Int? = nil | ||
var keyValue: Int? = nil | ||
} | ||
|
||
struct PlistColors: Codable { | ||
var tag: Int? | ||
var keyName: Int? | ||
var keyValue: Int? | ||
var header: Int? | ||
var comment: Int? | ||
var tag: Int? = nil | ||
var keyName: Int? = nil | ||
var keyValue: Int? = nil | ||
var header: Int? = nil | ||
var comment: Int? = nil | ||
} | ||
|
||
struct XmlColors: Codable { | ||
var punctuation: Int? | ||
var openingTag: Int? | ||
var closingTag: Int? | ||
var key: Int? | ||
var header: Int? | ||
var comment: Int? | ||
var punctuation: Int? = nil | ||
var openingTag: Int? = nil | ||
var closingTag: Int? = nil | ||
var key: Int? = nil | ||
var header: Int? = nil | ||
var comment: Int? = nil | ||
} | ||
|
||
/// Plist file to specify custom colors | ||
struct ColorFile: Codable { | ||
var json: JsonColors? | ||
var plist: PlistColors? | ||
var xml: XmlColors? | ||
var json: JsonColors? = nil | ||
var plist: PlistColors? = nil | ||
var xml: XmlColors? = nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import ArgumentParser | ||
|
||
enum Command: String, ExpressibleByArgument { | ||
case read, set, delete, add | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.