Skip to content

Commit

Permalink
Rearranging how main() works (ned14#73)
Browse files Browse the repository at this point in the history
- Instead of duplicating the code in main() and the __main__ condition
  this uses only main()
- main() now takes a list as input (the argv list)
- main() returns the exit code instead of calling sys.exit()
  • Loading branch information
assarbad committed Nov 14, 2022
1 parent 2ad25f1 commit 62658ba
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions pcpp/pcmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,11 @@ def on_comment(self,tok):
return True # Pass through
return super(CmdPreprocessor, self).on_comment(tok)

def main():
p = CmdPreprocessor(sys.argv)
sys.exit(p.return_code)
def main(argv=None):
if argv is None:
argv = sys.argv
p = CmdPreprocessor(argv)
return p.return_code

if __name__ == "__main__":
p = CmdPreprocessor(sys.argv)
sys.exit(p.return_code)
sys.exit(main(sys.argv))

0 comments on commit 62658ba

Please sign in to comment.