Skip to content

Commit

Permalink
Make main() more testable
Browse files Browse the repository at this point in the history
  • Loading branch information
lbonn committed Oct 31, 2019
1 parent ca40ba7 commit df3a9a2
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions git_archive_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,10 @@ def get_git_version(cls):
return None


def main():
def main(argv=None):
if argv is None:
argv = sys.argv

from optparse import OptionParser, SUPPRESS_HELP

parser = OptionParser(
Expand Down Expand Up @@ -538,7 +541,7 @@ def main():
dest='compresslevel',
help=SUPPRESS_HELP)

options, args = parser.parse_args()
options, args = parser.parse_args(argv[1:])

if len(args) != 1:
parser.error("You must specify exactly one output file")
Expand Down Expand Up @@ -575,8 +578,8 @@ def main():
except Exception as e:
parser.exit(2, "{0}\n".format(e))

sys.exit(0)
return 0


if __name__ == '__main__':
main()
sys.exit(main())

0 comments on commit df3a9a2

Please sign in to comment.