-
Notifications
You must be signed in to change notification settings - Fork 12
eng-1668: Add --yes option, --output=json, and improve table list display #83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
pokgak
wants to merge
20
commits into
main
Choose a base branch
from
feature/cli-improvements
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
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
- Add --yes/-y option to sandbox create/delete and pods create/terminate - Sort sandbox list by age (oldest first) - Change Created column to Age with human-friendly format (29m, 2h, 3d) Co-authored-by: Amp <amp@ampcode.com> Amp-Thread-ID: https://ampcode.com/threads/T-d686962a-b0a1-47d0-a329-43b3555d7591
- Add --output/-o option with table (default) or json formats - JSON output includes all sandbox data with proper API field names - Maintains backward compatibility with default table output Co-authored-by: Amp <amp@ampcode.com> Amp-Thread-ID: https://ampcode.com/threads/T-d686962a-b0a1-47d0-a329-43b3555d7591
- JSON output now matches table format scope - Excludes internal API fields like kubernetes_job_id, updated_at - Environment variables are obfuscated in JSON same as table - Maintains data privacy and consistency between formats
- Created _format_sandbox_for_list() and _format_sandbox_for_details() functions - Both table and JSON outputs now use the same underlying data model - Ensures consistent field exposure across output formats - Eliminates code duplication and reduces risk of inconsistencies
- Add proper type hints for _format_sandbox_for_list and _format_sandbox_for_details - Import Sandbox type and typing utilities - Explicit type annotation for data dict to satisfy mypy
- Validate that --output only accepts 'table' or 'json' - Show clear error message for invalid formats - Exit with code 1 on invalid format
- Created utils.py with shared functions: - validate_output_format() for output validation - output_data_as_json() for consistent JSON output - confirm_or_skip() for confirmation prompts with --yes support - Updated sandbox commands to use shared utilities - Added --output=json support to pods list command - Added --output=json support to env list command - Updated all confirmation prompts to use shared utility - Added JSON output validation for watch mode in pods list
- Added age formatting to pods list table output (29m, 2h, 3d format) - Changed Created column to Age column in pods list table - Keep timestamp in JSON output for automation needs - Updated sandbox list to also use timestamp in JSON (consistent approach) - Table format shows human-friendly age, JSON shows precise timestamps
- Added --output/-o option to 'prime pods status <id>' command - Created _format_pod_for_status() helper function for data formatting - JSON output includes all status data, port mappings, and attached resources - Table output uses same data source for consistency - Both formats show identical information with appropriate styling
- Added sorting by created_at timestamp in pods list command - Oldest pods now appear at the top, newest at the bottom - Consistent behavior with sandbox list sorting - Applied to both table and JSON output formats
- Added --output/-o option to 'prime availability list' command - Created _format_availability_for_display() helper function for data formatting - JSON output includes all availability data, filters, and count information - Table output uses same data source for consistency - Both formats show identical information with appropriate styling
Based on Oracle analysis, created structured utils package: - utils/time_utils.py: human_age(), iso_timestamp(), sort_by_created() - utils/display.py: build_table(), status_color(), common color mappings - utils/formatters.py: obfuscate_env_vars(), format_resources(), format_price() - utils/prompt.py: confirm_or_skip() Refactored sandbox.py to use new utilities: - Removed duplicate _format_age() and _obfuscate_env_vars() functions - Uses shared status color mappings and table building - Maintains backward compatibility with existing utils.py imports Benefits: - Single source of truth for time/formatting logic - Consistent styling across commands - Easier testing and maintenance - Foundation for future command refactoring
- Export format_resources function in utils/__init__.py - Fix undefined _obfuscate_env_vars reference in sandbox.py - Remove old utils.py compatibility module - All imports now use the unified utils/ package Co-authored-by: Amp <amp@ampcode.com> Amp-Thread-ID: https://ampcode.com/threads/T-d686962a-b0a1-47d0-a329-43b3555d7591
- Add type annotations to key_fn functions in time_utils.py - Fix typer.confirm return type in prompt.py - Resolve variable name conflict in availability.py - Use proper Pod and PodStatus types instead of Any in pods.py - Import Pod and PodStatus classes for type safety
- Fix function signature conflict in time_utils.py by using single key_fn with Union return type - Add explicit Dict[str, Any] type annotation to status_data in pods.py to resolve assignment errors - All real type errors now resolved (ignoring missing stub packages)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Major CLI usability improvements with consistent
--yes
flags,--output=json
support, human-friendly age display, and structured utilities for better maintainability.✨ New Features
1. Skip Confirmation Prompts (
--yes/-y
)Bypass interactive confirmations for automation and scripting.
Commands Updated:
prime sandbox create --yes
prime sandbox delete --yes
prime pod create --yes
prime pod terminate --yes
2. JSON Output Support (
--output=json
)Machine-readable output for automation with consistent field exposure.
Commands Updated:
prime sandbox list --output=json
prime sandbox get <id> --output=json
prime pods list --output=json
prime pods status <id> --output=json
prime env list --output=json
prime availability list --output=json
3. Human-Friendly Age Display
Tables show intuitive age format, JSON preserves precise timestamps.
Commands Updated:
prime sandbox list
- Age column (29m, 2h, 3d format)prime pods list
- Age column (29m, 2h, 3d format)4. Consistent List Sorting
All lists sorted chronologically with oldest items first.
Commands Updated:
prime sandbox list
- Sorted by creation timeprime pods list
- Sorted by creation time5. Structured Utilities Package
Extracted shared code into organized utility modules for better maintainability.
📋 Examples
Skip Confirmations (Great for Scripts)
JSON Output for Automation
Improved List Display
Detailed Status Information
🔧 Technical Details
Smart Output Format Selection:
Shared Utilities Architecture:
utils/time_utils.py
- Age formatting, timestamp handling, sortingutils/display.py
- Table building, status colors, JSON outpututils/formatters.py
- Resource formatting, price display, env var obfuscationutils/prompt.py
- Confirmation prompts with--yes
support