Add flag to dump read colors to console. Not very helpful if you want to use this in a pipeline
This commit is contained in:
parent
90a3ed745f
commit
911db304ae
2 changed files with 28 additions and 18 deletions
11
README.md
11
README.md
|
@ -16,20 +16,21 @@ If you don’t use Homebrew you can also install directly from source. Clone the
|
|||
## Usage
|
||||
|
||||
```
|
||||
USAGE: make-colors <input> [--ios] [--android] [--html] [--prefix <prefix>] [--output <output>]
|
||||
USAGE: make-colors <input> [--ios] [--android] [--html] [--prefix <prefix>] [--output <output>] [--dump]
|
||||
|
||||
ARGUMENTS:
|
||||
<input> The color list to process.
|
||||
Use - to process the standard input.
|
||||
|
||||
OPTIONS:
|
||||
--ios/--android/--html The formatter to use (default: ios)
|
||||
--prefix <prefix> Prefix for color names
|
||||
--ios/--android/--html The formatter to use. (default: ios)
|
||||
--prefix <prefix> Prefix for color names.
|
||||
--output <output> Output file to write.
|
||||
Use - for standard output.
|
||||
Default is the input file name with the appropriate file extension. If
|
||||
the input is read from the standard input the default is standard
|
||||
output.
|
||||
the input is - the default is standard output.
|
||||
Note that asset catalogs cannot be written to standard output.
|
||||
--dump List read colors on console.
|
||||
-h, --help Show help information.
|
||||
```
|
||||
|
||||
|
|
|
@ -60,6 +60,9 @@ public final class MakeColors: ParsableCommand, Context {
|
|||
@Option(help: HelpTexts.output)
|
||||
var output: String?
|
||||
|
||||
@Flag(help: "List read colors on console.")
|
||||
var dump = false
|
||||
|
||||
public init() {}
|
||||
|
||||
public func run() throws {
|
||||
|
@ -68,19 +71,8 @@ public final class MakeColors: ParsableCommand, Context {
|
|||
|
||||
let data = try scanner.colorList()
|
||||
|
||||
for (key, color) in data.sorted() {
|
||||
let resolved = try data.resolve(key)
|
||||
switch color {
|
||||
case .color:
|
||||
print(key.insertCamelCaseSeparators(), resolved, separator: ": ")
|
||||
|
||||
case let .reference(referenced):
|
||||
print(
|
||||
"\(key.insertCamelCaseSeparators()) (@\(referenced.insertCamelCaseSeparators()))",
|
||||
resolved,
|
||||
separator: ": "
|
||||
)
|
||||
}
|
||||
if dump {
|
||||
try dump(data: data)
|
||||
}
|
||||
|
||||
let generator = formatter.type.init(context: self)
|
||||
|
@ -109,6 +101,23 @@ public final class MakeColors: ParsableCommand, Context {
|
|||
return input
|
||||
}
|
||||
|
||||
func dump(data: [String: ColorDef]) throws {
|
||||
for (key, color) in data.sorted() {
|
||||
let resolved = try data.resolve(key)
|
||||
switch color {
|
||||
case .color:
|
||||
print(key.insertCamelCaseSeparators(), resolved, separator: ": ")
|
||||
|
||||
case let .reference(referenced):
|
||||
print(
|
||||
"\(key.insertCamelCaseSeparators()) (@\(referenced.insertCamelCaseSeparators()))",
|
||||
resolved,
|
||||
separator: ": "
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func writeOutput(_ wrapper: FileWrapper) throws {
|
||||
if shouldWriteToStdout {
|
||||
guard wrapper.isRegularFile, let contents = wrapper.regularFileContents else {
|
||||
|
|
Loading…
Add table
Reference in a new issue