Skip to content

Commit

Permalink
🍀 refactor - inline if elses.
Browse files Browse the repository at this point in the history
Issue: #10
  • Loading branch information
gopinath-langote committed May 12, 2019
1 parent 06ebd4c commit a85af77
Showing 1 changed file with 7 additions and 17 deletions.
24 changes: 7 additions & 17 deletions 1build
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ class Project:
if cmd.name == command_name:
return cmd
else:
raise ValueError("No command '" + command_name + "' found in config file " + __build_file_name__() + "\n\n" +
__help_message__(self)
)
raise ValueError(
"No command '" + command_name + "' found in config file " + __build_file_name__() + "\n\n" +
__help_message__(self)
)

def __has_command__(self, command_name):
for cmd in self.commands:
Expand All @@ -47,17 +48,12 @@ class Command:


def run(build_file_name, arguments):
"""
:param build_file_name: parametrize build file name & update the global BUILD_FILE_NAME variable with this value
:param arguments: command line arguments will be passed here
"""
global BUILD_FILE_NAME
BUILD_FILE_NAME = build_file_name

try:
project = __parse_project_config__()
command_name = command_to_run(arguments)
if command_name.lower() == "help":
if command_name == "help":
print(__help_message__(project))
else:
command = project.get_command(command_name)
Expand All @@ -68,10 +64,7 @@ def run(build_file_name, arguments):

def execute(command, before=None, after=None):
cmd = command.cmd

print(dash)
print("Name: " + command.name)
print("Command: " + command.cmd)
print(dash + "\nName: " + command.name + "\nCommand: " + command.cmd)
if before:
print("Before: " + before)
cmd = before + " && " + cmd
Expand Down Expand Up @@ -119,10 +112,7 @@ def __build_file_name__(): return "'" + BUILD_FILE_NAME + "'"


def command_to_run(arguments):
if len(arguments) is 1:
return "help"
else:
return arguments[1]
return "help" if len(arguments) == 1 else arguments[1]


def sample_yaml_file():
Expand Down

0 comments on commit a85af77

Please sign in to comment.