-
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.
Merge pull request #68 from ABridoux/bugfix/65-Lux-json-escaped-quotes
[#68] Lux json escaped quotes
- Loading branch information
Showing
18 changed files
with
578 additions
and
334 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,72 @@ | ||
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 can add multiple values in one command | ||
- Specify the \(zshInjector.delegate.inject(.optionNameOrFlag, in: .terminal, "-v")) flag to see the modified data | ||
- Deactivate the output colorization with \(zshInjector.delegate.inject(.optionNameOrFlag, in: .terminal, "--no-color")). | ||
Useful if you encounter slowdowns when dealing with large files although it is not recommended not ouput large files in the terminal. | ||
- 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
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.