Skip to content

Commit

Permalink
fix messaging and colors for meta targets
Browse files Browse the repository at this point in the history
  • Loading branch information
nsheff committed Sep 26, 2023
1 parent 58583d4 commit 024378b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
6 changes: 3 additions & 3 deletions markmeld/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,10 @@ def report_result(built_target):
_LOGGER.debug(f"Built target: {built_target}")
for item in built_target.messages:
if item["status"] == "fail":
color_code = "\033[0;31m" # red
color_code = "\x1b[31;20m" # red
else:
color_code = " \032[0;31m" # green
_LOGGER.info(f"{color_code}{item['status']}: {item['message']}\033[0m")
color_code = "\x1b[32;20m" # green
_LOGGER.info(f"{color_code}{item['status']}: {item['message']}\x1b[0m")

if built_target.returncode != 0:
_LOGGER.error("Building target failed")
Expand Down
11 changes: 9 additions & 2 deletions markmeld/melder.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,8 @@ def build_target(self, target_name, print_only=False, vardump=False):
_LOGGER.info(f"MM | Building target: {tgt.target_name} from file {tgt.meta['_cfg_file_path']}")

# First, run any pre-builds
if not self.build_side_targets(tgt, "prebuild"):
prebuild_results = self.build_side_targets(tgt, "prebuild")
if not prebuild_results:
_LOGGER.debug("Failed building prebuild side targets")
return tgt

Expand All @@ -422,7 +423,9 @@ def build_target(self, target_name, print_only=False, vardump=False):
result = self.run_command_for_target(tgt, print_only, vardump)

# Finally, run any postbuilds
if not self.build_side_targets(tgt, "postbuild"):
postbuild_results = self.build_side_targets(tgt, "postbuild")
if not postbuild_results:
_LOGGER.debug("Failed building postbuild side targets")
return tgt

return result
Expand All @@ -443,6 +446,10 @@ def build_side_targets(self, tgt, side_list_key="prebuild"):
_LOGGER.info(f"MM | {side_list_key} target: {side_tgt}")
if side_tgt in self.cfg["targets"]:
self.build_target(side_tgt)
tgt.add_message(
f"MM | Built {side_list_key} target '{side_tgt}' requested by target '{tgt.target_name}' from file '{tgt.meta['_cfg_file_path']}'",
"success",
)
else:
tgt.add_message(
f"MM | No target called '{side_tgt}', requested prebuild by target '{tgt.target_name}' from file '{tgt.meta['_cfg_file_path']}'",
Expand Down

0 comments on commit 024378b

Please sign in to comment.