docopt / docopt.go

A command-line arguments parser that will make you smile.
http://docopt.org/
MIT License
1.43k stars 108 forks source link

Rename parse() to ParseSafe() #8

Closed mboersma closed 10 years ago

mboersma commented 10 years ago

The docopt.go API is the simple Parse() function. But on bad input or an implied usage request, Parse() calls os.Exit(). For library-type code, that is bad form in Go. In practice, it makes it impossible to write tests for a command-line tool using docopt, since there is no way to trap os.Exit(), and there is no alternate docopt.go API to Parse().

This pull request exports the parse() implementation function by renaming it to ParseSafe(). No existing uses of Parse() will break, and those who need to avoid os.Exit() or write tests can call ParseSafe() instead.

Fixes #7.

mboersma commented 10 years ago

@kbatten, do you have any feedback on this PR? I can't really move forward on my TDD client project without this, unless I'm working off my own fork.

mboersma commented 10 years ago

Closing this PR in favor of https://github.com/docopt/docopt.go/pull/9.