Skip to content

Commit

Permalink
Add deprecation warning for the mol command (#3407)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Sorin Sbarnea <[email protected]>
  • Loading branch information
3 people authored Feb 6, 2022
1 parent fa95493 commit b7881b6
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ lint =
[options.entry_points]
console_scripts =
molecule = molecule.__main__:main
mol = molecule.__main__:main
mol = molecule.__main__:mol_deprecation_notice
molecule.driver =
delegated = molecule.driver.delegated:Delegated
molecule.verifier =
Expand Down
15 changes: 15 additions & 0 deletions src/molecule/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,22 @@
# DEALINGS IN THE SOFTWARE.
"""Molecule CLI main entry point."""

import warnings

from molecule.shell import main


def mol_deprecation_notice():
"""Display a deprecation notice about mol command."""
try:
main()
except BaseException:
warnings.warn(
"The `mol` command is deprecated and will be removed in a future version of Molecule. If you wish to continue using it, please create an alias that calls `molecule`.",
category=UserWarning,
)
raise


if __name__ == "__main__":
main()
5 changes: 3 additions & 2 deletions src/molecule/test/unit/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,6 @@ def test_cli_mol():
cmd_mol = ["mol", "--version"]
y = util.run_command(cmd_mol)
assert x.returncode == y.returncode
assert x.stderr == y.stderr
assert x.stdout == y.stdout
assert x.stderr in y.stderr
assert x.stdout in y.stdout
assert "UserWarning" in y.stdout

0 comments on commit b7881b6

Please sign in to comment.