docopt.coffee icon indicating copy to clipboard operation
docopt.coffee copied to clipboard

Cleaner module.exports

Open thetrompf opened this issue 10 years ago • 2 comments

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.

thetrompf avatar Jul 08 '14 18:07 thetrompf

@sonwell, are you still maintaining this project?

keleshev avatar Jul 14 '14 20:07 keleshev

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.

sonwell avatar Jul 15 '14 05:07 sonwell