Created
December 6, 2022 08:44
-
-
Save pvergain/d77030433a59ccba27c5dcf3773ac806 to your computer and use it in GitHub Desktop.
call slugify from the command line
This file contains hidden or 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
"""slug.py | |
- https://github.com/un33k/python-slugify | |
Exemple d'appel | |
================== | |
:: | |
python slug.py --text "un projet gitlab pour les issues" | |
:: | |
un-projet-gitlab-pour-les-issues | |
:: | |
python slug.py --text "un projet gitlab pour les Issues très graves" | |
:: | |
un-projet-gitlab-pour-les-issues-tres-graves | |
""" | |
import sys | |
from slugify import slugify | |
def get_slug(text: str): | |
slug = slugify(text) | |
print(slug) | |
if __name__ == "__main__": | |
"""Point d'entrée du script Python.""" | |
text = "" | |
for i, argument in enumerate(sys.argv): | |
if argument == "--text": | |
text = sys.argv[i + 1] | |
get_slug(text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment