Skip to content
This repository has been archived by the owner on Jan 14, 2024. It is now read-only.

Commit

Permalink
Refactor to make testable: RiotKitDoApplication
Browse files Browse the repository at this point in the history
  • Loading branch information
blackandred committed May 8, 2020
1 parent bb6893c commit 90b6fe0
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/rkd/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ class RiotKitDoApplication:
_ctx: Context
_tasks_to_execute = []

def main(self):
if not sys.argv[1:]:
def main(self, argv: list):
if not argv[1:]:
self.print_banner_and_exit()

try:
Expand All @@ -32,7 +32,7 @@ def main(self):
executor = OneByOneTaskExecutor(self._ctx)

# iterate over each task, parse commandline arguments
requested_tasks = CommandlineParsingHelper.create_grouped_arguments([':init'] + sys.argv[1:])
requested_tasks = CommandlineParsingHelper.create_grouped_arguments([':init'] + argv[1:])

# validate all tasks
resolver.resolve(requested_tasks, TaskDeclarationValidator.assert_declaration_is_valid)
Expand All @@ -55,9 +55,10 @@ def print_banner_and_exit():

sys.exit(0)


def main():
app = RiotKitDoApplication()
app.main()
app.main(argv=sys.argv)


if __name__ == '__main__':
Expand Down

0 comments on commit 90b6fe0

Please sign in to comment.