Improve usage message and add to README
This commit is contained in:
parent
abc0ef910d
commit
13f985c0a4
2 changed files with 44 additions and 5 deletions
20
README.md
20
README.md
|
@ -13,6 +13,26 @@ brew install make-colors
|
|||
|
||||
If you don’t use Homebrew you can also install directly from source. Clone the repository or download the release and run `make install` inside the working copy.
|
||||
|
||||
## Usage
|
||||
|
||||
```
|
||||
USAGE: make-colors <input> [--ios] [--android] [--html] [--prefix <prefix>] [--output <output>]
|
||||
|
||||
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
|
||||
--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.
|
||||
-h, --help Show help information.
|
||||
```
|
||||
|
||||
## Input format
|
||||
|
||||
Each line in your input contains one color definition. That is a name followed by the actual color. We support RGB colors in a few formats similar to CSS:
|
||||
|
|
|
@ -28,17 +28,36 @@ enum Errors: Error {
|
|||
case cannotReadStdin
|
||||
}
|
||||
|
||||
enum HelpTexts {
|
||||
static let input = ArgumentHelp(
|
||||
"The color list to process.",
|
||||
discussion: """
|
||||
Use - to process the standard input.
|
||||
"""
|
||||
)
|
||||
|
||||
static let output = ArgumentHelp(
|
||||
"Output file to write.",
|
||||
discussion: """
|
||||
Use - for standard output.
|
||||
Default is the input file name with the appropriate file extension. \
|
||||
If the input is - the default is standard output.
|
||||
Note that asset catalogs cannot be written to standard output.
|
||||
"""
|
||||
)
|
||||
}
|
||||
|
||||
public final class MakeColors: ParsableCommand, Context {
|
||||
@Argument(help: "The color list to proces")
|
||||
@Argument(help: HelpTexts.input)
|
||||
var input: String
|
||||
|
||||
@Flag(help: "The formatter to use")
|
||||
@Flag(help: "The formatter to use.")
|
||||
private var formatter = GeneratorOption.allCases[0]
|
||||
|
||||
@Option(help: "Prefix for color names")
|
||||
@Option(help: "Prefix for color names.")
|
||||
var prefix: String?
|
||||
|
||||
@Option(help: "Output file")
|
||||
@Option(help: HelpTexts.output)
|
||||
var output: String?
|
||||
|
||||
public init() {}
|
||||
|
@ -103,7 +122,7 @@ public final class MakeColors: ParsableCommand, Context {
|
|||
}
|
||||
}
|
||||
|
||||
var shouldWriteToStdout: Bool { input == "-" && output == nil }
|
||||
var shouldWriteToStdout: Bool { output == "-" || (input == "-" && output == nil) }
|
||||
|
||||
func outputURL(extension: String) -> URL {
|
||||
if let output = output {
|
||||
|
|
Loading…
Add table
Reference in a new issue