diff options
| -rw-r--r-- | README.md | 45 | ||||
| -rw-r--r-- | src/porkbun/cli.py | 6 |
2 files changed, 28 insertions, 23 deletions
@@ -8,7 +8,7 @@ A Python CLI tool for bulk querying domain pricing information from the Porkbun - **Domain availability checking** - Shows if domains are available for registration - JSON Lines output format - SQLite caching to avoid duplicate API calls -- **Verbose mode with progress bars** - Visual feedback for long-running queries +- **Progress bars by default** - Visual feedback for all queries (disable with `-q`) - Aggressive 429 retry handling - Async implementation for performance - Multiple credential sources (CLI, env vars, config file) @@ -55,9 +55,13 @@ porkbun test_domains.txt ### Query from File ```bash -# Basic usage (reads credentials from config file) +# Basic usage (shows progress bars by default) porkbun test_domains.txt +# Quiet mode (disable progress bars, JSON only) +porkbun test_domains.txt --quiet +porkbun test_domains.txt -q + # Refresh data from API and update cache porkbun test_domains.txt --refresh @@ -66,25 +70,23 @@ porkbun test_domains.txt --clear-cache # Debug mode (shows full HTTP requests/responses and status) porkbun test_domains.txt --debug - -# Verbose mode (shows progress bars for API requests) -porkbun test_domains.txt --verbose ``` ### Query Single/Multiple Domains ```bash -# Single domain +# Single domain (shows progress bar by default) porkbun -d example.com porkbun --domain example.com -# Multiple domains +# Multiple domains (shows progress for each) porkbun -d example.com -d test.net -d sample.org +# Quiet mode for clean JSON output (useful for piping) +porkbun -d example.com -q +echo "example.com\ntest.net" | porkbun --quiet + # Combined with other flags porkbun -d example.com --refresh --debug - -# With progress bars -porkbun -d domain1.com -d domain2.com -d domain3.com --verbose ``` ## Debug Mode @@ -124,9 +126,9 @@ Body: {"status":"SUCCESS","pricing":{...}} **Note:** JSON results always go to stdout, debug/status messages go to stderr for easy separation. -## Verbose Mode +## Progress Bars -When `--verbose` is specified, the tool shows real-time progress bars for each domain being processed: +**By default**, the tool shows real-time progress bars for each domain being processed. Use `-q` or `--quiet` to disable this for clean JSON-only output. **Features:** - Overall progress bar showing total completion @@ -137,7 +139,7 @@ When `--verbose` is specified, the tool shows real-time progress bars for each d - 🔴 Red: Error occurred - Shows whether data came from cache or API -**Example output:** +**Example output (default):** ``` Processing domains... ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% example.com - ✓ From cache ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% @@ -145,17 +147,18 @@ When `--verbose` is specified, the tool shows real-time progress bars for each d sample.org - ✓ Complete ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% ``` -**Use with file input:** -```bash -porkbun domains.txt --verbose -``` - -**Use with multiple domains:** +**Disable progress bars for piping:** ```bash -porkbun -d domain1.com -d domain2.com -d domain3.com --verbose +# Clean JSON output only (no progress bars) +porkbun domains.txt -q > results.jsonl +porkbun -d example.com --quiet | jq . ``` -**Note:** Verbose mode is especially useful when processing many domains, as it provides visual feedback on progress and shows which domains are being fetched vs cached. +**When to use quiet mode:** +- Piping output to other tools +- Scripting and automation +- When you only want the JSON output +- Redirecting to files ## Input Format diff --git a/src/porkbun/cli.py b/src/porkbun/cli.py index 5843f34..c4496d8 100644 --- a/src/porkbun/cli.py +++ b/src/porkbun/cli.py @@ -166,8 +166,8 @@ async def async_main(domains: list[str], api_key: str, secret_key: str, refresh: @click.option('--refresh', is_flag=True, help='Refresh data from API and update cache') @click.option('--clear-cache', is_flag=True, help='Clear the cache before running') @click.option('--debug', is_flag=True, help='Show detailed request/response information') -@click.option('--verbose', is_flag=True, help='Show progress bars for API requests') -def main(domains_file: Optional[Path], domains: tuple[str], api_key: Optional[str], secret_key: Optional[str], refresh: bool, clear_cache: bool, debug: bool, verbose: bool): +@click.option('-q', '--quiet', is_flag=True, help='Disable progress bars (show only JSON output)') +def main(domains_file: Optional[Path], domains: tuple[str], api_key: Optional[str], secret_key: Optional[str], refresh: bool, clear_cache: bool, debug: bool, quiet: bool): """Query domain pricing from Porkbun API. Accepts domains either from a file (one domain per line) or via -d/--domain flags. @@ -200,6 +200,8 @@ def main(domains_file: Optional[Path], domains: tuple[str], api_key: Optional[st domain_list = list(domains) resolved_api_key, resolved_secret_key = resolve_credentials(api_key, secret_key) + # Verbose is enabled by default, disabled with -q/--quiet + verbose = not quiet asyncio.run(async_main(domain_list, resolved_api_key, resolved_secret_key, refresh, clear_cache, debug, verbose)) |
