-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Wrap commands in __main__ to prepend 'covimerage: ' prefix with errors.
- Loading branch information
Showing
3 changed files
with
27 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,26 @@ | ||
if __name__ == '__main__': | ||
def wrap_for_errormsg(f, *args, **kwargs): | ||
try: | ||
f(*args, standalone_mode=False, **kwargs) | ||
except Exception as exc: | ||
from click.exceptions import ClickException | ||
if isinstance(exc, ClickException): | ||
import sys | ||
from click.utils import echo | ||
|
||
msg = 'covimerage: error: %s' % (exc.format_message(),) | ||
echo(msg, err=True) | ||
sys.exit(2) | ||
|
||
|
||
def main(): | ||
from .cli import main | ||
wrap_for_errormsg(main.main, prog_name='covimerage') | ||
|
||
|
||
def run(): | ||
from .cli import run | ||
wrap_for_errormsg(run.main, prog_name='covimerage-run') | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters