#!/usr/bin/env python3 # QUOTES: A lightweight cross-platform Python-based random quote generator. # Blue Oak Council License 1.0.0 - https://blueoakcouncil.org/license/1.0.0 # Copyright (c) 2025 https://640kb.neocities.org import os import random import sys # .-----------------------------------------------------------------. # | Quick Start Examples: | # | | # | Linux: quotes or quotes somefile | # | macOS: quotes or quotes path/to/file.txt | # | Windows: python quotes.py or python quotes.py file.txt | # | | # | Notes: | # | The script and quotes.txt must be in the same directory, | # | unless you provide a full or relative path to the file. | # | | # | On Linux/macOS: run "chmod +x quotes" to make it executable. | # '-----------------------------------------------------------------' # Default quotes file name (or "quotes anyFilename.txt") QUOTE_FILE = 'quotes.txt' def get_random_quote(file_path): try: with open(file_path, 'r') as file: lines = [line.strip() for line in file if line.strip() and not line.strip().startswith('#')] if not lines: return "No quotes available." return random.choice(lines) except FileNotFoundError: return f"Error: Quote file '{file_path}' not found." if __name__ == "__main__": # Use command-line argument if provided, otherwise use default QUOTE_FILE quote_file = sys.argv[1] if len(sys.argv) > 1 else QUOTE_FILE quote = get_random_quote(quote_file) print(f"\n{quote}\n")