Skip to content

Commit

Permalink
feat: Adds optional description of command describer
Browse files Browse the repository at this point in the history
  • Loading branch information
devedbox committed Oct 29, 2018
1 parent aa52310 commit 0d4fd23
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Sources/Commander/Commands/CommandDescriber.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,14 @@ internal struct CommandDescriber {
let optionsSymbols = command.optionsDescriber.descriptions.map { desc -> (String, String) in
let shortKey = command.optionsDescriber.keys[desc.key]
let keyDesc = (shortKey.map { "-\($0), " } ?? "") + "--\(desc.key)"
return (keyDesc, desc.value.usage)

var usage = desc.value.usage
if let defaultValue = desc.value.defaultValue {
let separator = usage.hasSuffix(".") ? "" : "."
usage += separator + " Optional with default value: '\(defaultValue)'"
}

return (keyDesc, usage)
}
let argumentsSymbols: [(String, String)] = command.optionsDescriber.isArgumentsResolvable == false ? [] : [
("[\(String(describing: command.optionsDescriber.argumentType))]", "\(path) \(command.symbol) [options] arg1 arg2 ...")
Expand Down

0 comments on commit 0d4fd23

Please sign in to comment.