Skip to content

Commit

Permalink
H Support help command
Browse files Browse the repository at this point in the history
Issue: #8
  • Loading branch information
gopinath-langote committed Apr 25, 2019
1 parent d2849b7 commit fa3d6d0
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions 1build
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@ import sys
def run(arguments):
try:
project = parse_project_config()
command = project.get_command(command_to_run(arguments))
execute(command)
command_name = command_to_run(arguments)
if command_name.lower() == "help":
print help_message(project)
else:
command = project.get_command(command_name)
execute(command)
except ValueError as error:
print error

Expand All @@ -25,9 +29,8 @@ class Project:
if cmd.name == command_name:
return cmd
else:
raise ValueError("No command " + command_name + " found in config file `1build.yaml` \n" +
"Available commands:" + "\n" +
self.available_commands()
raise ValueError("No command " + command_name + " found in config file `1build.yaml` \n\n" +
help_message(self)
)

def __has_command__(self, command_name):
Expand Down Expand Up @@ -85,6 +88,10 @@ def parse_project_config():
return Project(name=(content["project"]), commands=(get_command_list_from_config(content["commands"])))


def help_message(project):
return "Usage: 1build <command_name> \n\n" + project.__str__()


def command_to_run(arguments):
if len(arguments) is 1:
return "build"
Expand Down

0 comments on commit fa3d6d0

Please sign in to comment.