diff --git a/README.md b/README.md
index 04ab603..26464a0 100644
--- a/README.md
+++ b/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 [--ios] [--android] [--html] [--prefix ] [--output ]
+
+ARGUMENTS:
+ The color list to process.
+ Use - to process the standard input.
+
+OPTIONS:
+ --ios/--android/--html The formatter to use (default: ios)
+ --prefix Prefix for color names
+ --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:
diff --git a/Sources/LibMakeColors/MakeColors.swift b/Sources/LibMakeColors/MakeColors.swift
index 3b4e7f5..3140601 100644
--- a/Sources/LibMakeColors/MakeColors.swift
+++ b/Sources/LibMakeColors/MakeColors.swift
@@ -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 {