feat(cli): add context show and session status commands#3096
feat(cli): add context show and session status commands#3096atharvalade wants to merge 5 commits intoapache:masterfrom
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #3096 +/- ##
=============================================
- Coverage 74.08% 53.11% -20.98%
Complexity 943 943
=============================================
Files 1159 1150 -9
Lines 102033 90218 -11815
Branches 79084 67422 -11662
=============================================
- Hits 75593 47919 -27674
- Misses 23770 39744 +15974
+ Partials 2670 2555 -115
🚀 New features to boost your workflow:
|
|
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. If you need a review, please ensure CI is green and the PR is rebased on the latest master. Don't hesitate to ping the maintainers - either @core on Discord or by mentioning them directly here on the PR. Thank you for your contribution! |
|
|
||
| Ok(()) | ||
| } | ||
| } |
There was a problem hiding this comment.
missing tests covering explain / login_required / connection_required. sibling delete_context.rs:67-83 has the pattern.
|
|
||
| Ok(()) | ||
| } | ||
| } |
There was a problem hiding this comment.
same gap as show_context.rs - no unit tests for explain / login_required / connection_required. mirror delete_context.rs:67-83.
| if let Some(ref transport) = config.iggy.transport { | ||
| table.add_row(vec!["Transport", transport]); | ||
| } | ||
| if let Some(ref addr) = config.iggy.tcp_server_address { | ||
| table.add_row(vec!["TCP Server Address", addr]); | ||
| } | ||
| if let Some(ref url) = config.iggy.http_api_url { | ||
| table.add_row(vec!["HTTP API URL", url]); | ||
| } | ||
| if let Some(ref addr) = config.iggy.quic_server_address { | ||
| table.add_row(vec!["QUIC Server Address", addr]); | ||
| } | ||
| if let Some(tls) = config.iggy.tcp_tls_enabled { | ||
| table.add_row(vec!["TCP TLS Enabled", &tls.to_string()]); | ||
| } | ||
| if let Some(ref username) = config.username { | ||
| table.add_row(vec!["Username", username]); | ||
| } | ||
| if config.password.is_some() { | ||
| table.add_row(vec!["Password", MASKED_VALUE]); | ||
| } | ||
| if config.token.is_some() { | ||
| table.add_row(vec!["Token", MASKED_VALUE]); | ||
| } | ||
| if let Some(ref token_name) = config.token_name { | ||
| table.add_row(vec!["Token Name", token_name]); | ||
| } |
There was a problem hiding this comment.
only displays the subset of ArgsOptional matching ContextCreateArgs flags. drops config.extra (BTreeMap of preserved unknown TOML keys, see common.rs:54-55 and the round-trip test common.rs:734-756), tcp_tls_domain, tcp_reconnection_*, http_retries, websocket_server_address, all quic_* tuning fields, encryption_key, credentials_username / credentials_password. doc at args/context.rs:67 claims "full configuration" - promise not kept. either iterate extra and append the remaining iggy.* fields, or trim the doc to match implementation.
| #[async_trait] | ||
| impl CliCommand for ShowContextCmd { | ||
| fn explain(&self) -> String { | ||
| format!("show context \"{}\"", self.context_name) |
There was a problem hiding this comment.
quotes the name: format!("show context \"{}\"", ...). siblings delete_context.rs:41, use_context.rs, create_context.rs use unquoted form ("delete context {context_name}"). pick one.
| } | ||
|
|
||
| async fn execute_cmd(&mut self, _client: &dyn Client) -> anyhow::Result<(), anyhow::Error> { | ||
| let is_active = self.server_session.is_active(); |
There was a problem hiding this comment.
is_active() (session.rs:45-51) only checks whether the keyring entry exists. a stale or expired token still reports Active=Yes. either note this in the command output (e.g. "Session Active: Yes (token freshness not verified)") or document the limitation in the command's doc comment.
| for (key, value) in &self.expected_fields { | ||
| command_state = command_state | ||
| .stdout(contains(key.as_str())) | ||
| .stdout(contains(value.as_str())); | ||
| } |
There was a problem hiding this comment.
asserts key and value substrings independently. the test passes even if the table renders rows in mismatched order (e.g. "Username" appearing without its value, or vice versa). use a row-aware predicate or a single combined substring like "Username | admin".
| if is_active { | ||
| table.add_row(vec!["Session Active", "Yes"]); | ||
| } else { | ||
| table.add_row(vec!["Session Active", "No"]); | ||
| } |
There was a problem hiding this comment.
duplicates the add_row call. collapse to:
let active = if is_active { "Yes" } else { "No" };
table.add_row(vec!["Session Active", active]);
Which issue does this PR close?
Closes #3000
Rationale
The CLI lacked observability into context configuration and login session state, forcing users to manually read
~/.iggy/contexts.tomlor run authenticated commands to check connectivity.What changed?
Previously there was no way to inspect what a context contains or whether a login session is active without workarounds. Users had to read raw TOML files or run
iggy meand hope it worked.This adds
iggy context show <name>to display a named context's full configuration (transport, addresses, TLS, credentials with masking) andiggy session statusto check the local keyring for an active login session and show which server it targets — both without requiring a server connection.Local Execution
AI Usage