Instead of python as scripts that are run in bash, it would be nice to have some uv script that in run as a command. For example, something like the script below
#!/usr/bin/env -S uv run --script
# /// script
# requires-python = ">=3.13"
# dependencies = [
# "docopt==0.6.2",
# "requests<3",
# "rich",
# ]
# ///
##? Fetch and display PEP titles.
##?
##? Usage:
##? test <a> <b> <c> [<d>]
##?
##? Options:
##? <d> Optional argument. [default: "default_value"]
from docopt import docopt
import re
def get_help(filename):
"""
Extrai o conteúdo de ajuda de um arquivo.
Args:
filename (str): Caminho para o arquivo.
Returns:
list: Linhas de ajuda extraídas do arquivo.
"""
help_line_regex = r'^##\? ?'
help_lines = []
with open(filename, 'r') as file:
for line in file:
if re.match(help_line_regex, line):
# Remove o prefixo '##?' e espaços extras
help_lines.append(re.sub(help_line_regex, '', line.strip()))
return "\n".join(help_lines)
if __name__ == "__main__":
help_text = get_help(__file__)
arguments = docopt(help_text, version='Fetch PEP Titles 1.0')
print("Argumentos recebidos:")
for key, value in arguments.items():
print(f"{key}: {value}")
It might be possible looking for *.py files that starts with the uv shebang, and a change in the docopt file to allow search in python files
Instead of python as scripts that are run in bash, it would be nice to have some uv script that in run as a command. For example, something like the script below
It might be possible looking for *.py files that starts with the uv shebang, and a change in the docopt file to allow search in python files