docopt.coffee
docopt.coffee copied to clipboard
Cleaner module.exports
In docopt.coffee you use
module.exports =
docopt: docopt
... : ...
And that is all great but your list is now very long, and you have long names in it too, which makes it a problem to align, because you will have to change "all" the lines in module.exports = {}
just because a longer name comes along.
Coffeescript have a nice way to create object hashes when the key names are equal to the variable names:
module.exports = {
docopt
Option
Argument
Command
Required
AnyOptions
Either
Optional
Pattern
OneOrMore
TokenStream
Dict
formal_usage
parse_doc_options
parse_pattern
parse_long
parse_shorts
parse_args
printable_usage
}
This way you don't need anything to align, and it is easy to add new key/value pairs with out change any other lines in the object hash.
@sonwell, are you still maintaining this project?
I don't really have the time to.
In any case, I think eventually module.exports will be pretty simple. All of the classes, functions, etc. are exposed for testing.