Skip to content

Commit

Permalink
New option --bail
Browse files Browse the repository at this point in the history
  • Loading branch information
Josef-Friedrich committed Jan 21, 2024
1 parent 4d485a4 commit 8bc572b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
22 changes: 10 additions & 12 deletions mscxyz/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ def _split_lines(self, text: typing.Text, width: int) -> typing.List[str]:
help="Create a backup file.",
)

parser.add_argument(
"--bail",
dest="general_bail",
action="store_true",
help="Stop execution when an exception occurs.",
)

parser.add_argument(
"-k",
Expand All @@ -110,7 +116,6 @@ def _split_lines(self, text: typing.Text, width: int) -> typing.List[str]:
help="Simulate the actions.",
)


parser.add_argument(
"-m",
"--mscore",
Expand All @@ -127,7 +132,6 @@ def _split_lines(self, text: typing.Text, width: int) -> typing.List[str]:
help="Show a diff of the XML file before and after the manipulation.",
)


file_completers.append(
parser.add_argument(
"-e",
Expand All @@ -138,7 +142,6 @@ def _split_lines(self, text: typing.Text, width: int) -> typing.List[str]:
)
)


parser.add_argument(
"-v",
"--verbose",
Expand Down Expand Up @@ -663,13 +666,6 @@ def __print_error(error: Exception) -> None:
)


# def __no_error(error: Type[LxmlError], errors: list[Exception]) -> bool:
# for e in errors:
# if isinstance(e, error):
# return False
# return True


def execute(cli_args: Sequence[str] | None = None) -> None:
args = parse_args(parser, cli_args)

Expand Down Expand Up @@ -751,7 +747,6 @@ def list_styles(version: int) -> None:
if args.style_show_footer is not None:
score.style.show_footer = args.style_show_footer

# print("\n" + utils.color(file, "red"))
if args.lyrics_remap:
score.lyrics.remap(args.lyrics_remap)

Expand Down Expand Up @@ -843,4 +838,7 @@ def list_styles(version: int) -> None:
score.save()

except Exception as e:
__print_error(e)
if args.general_bail:
raise e
else:
__print_error(e)
1 change: 1 addition & 0 deletions mscxyz/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

class DefaultArguments:
general_backup: bool = False
general_bail: bool = False
general_colorize: bool = False
general_config_file: Optional[str] = None
general_diff: bool = False
Expand Down
1 change: 1 addition & 0 deletions tests/test_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,7 @@ def test_distribute_field_multiple_values(self) -> None:
def test_distribute_field_invalid_format_string(self) -> None:
with pytest.raises(meta.FormatStringNoFieldError):
Cli(
"--bail",
"--distribute-field",
"vbox_title",
"lol",
Expand Down

0 comments on commit 8bc572b

Please sign in to comment.