Skip to content
Snippets Groups Projects
Commit 87a5f4f3 authored by Jakob Moser's avatar Jakob Moser
Browse files

Add fortune cow

parent 7b3047fa
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/env python3
import subprocess
from typing import Optional
def _run(executable: str, argument: Optional[str] = None) -> str:
cmd = [executable, argument] if argument else [executable]
result = subprocess.run(cmd, capture_output=True, text=True, check=True)
return result.stdout.strip()
def get_fortune() -> str:
return _run("/usr/games/fortune")
def get_cowsay(text: str) -> str:
return _run("/usr/games/cowsay", text)
if __name__ == "__main__":
fortune_text = get_fortune()
cow_saying_fortune = get_cowsay(fortune_text)
print()
print("And the cow of the day says:")
print(cow_saying_fortune)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment