You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iggy.apache.org by "atharvalade (via GitHub)" <gi...@apache.org> on 2026/04/10 20:13:22 UTC
[PR] feat(cli): add context show and session status commands [iggy]
atharvalade opened a new pull request, #3096:
URL: https://github.com/apache/iggy/pull/3096
## 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.toml` or 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 me` and hope it worked.
This adds `iggy context show <name>` to display a named context's full configuration (transport, addresses, TLS, credentials with masking) and `iggy session status` to check the local keyring for an active login session and show which server it targets — both without requiring a server connection.
## Local Execution
- Passed
- Pre-commit hooks ran
## AI Usage
1. Opus 4.6
2. Minimal AI used
3. Yes all code can be explained
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@iggy.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(cli): add context show and session status commands [iggy]
Posted by "atharvalade (via GitHub)" <gi...@apache.org>.
atharvalade commented on code in PR #3096:
URL: https://github.com/apache/iggy/pull/3096#discussion_r3190970917
##########
core/cli/src/commands/binary_context/show_context.rs:
##########
@@ -0,0 +1,114 @@
+/* Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use anyhow::bail;
+use async_trait::async_trait;
+use comfy_table::Table;
+use tracing::{Level, event};
+
+use crate::commands::cli_command::{CliCommand, PRINT_TARGET};
+use iggy_common::Client;
+
+use super::common::{ContextConfig, ContextManager};
+
+const MASKED_VALUE: &str = "********";
+
+pub struct ShowContextCmd {
+ context_name: String,
+}
+
+impl ShowContextCmd {
+ pub fn new(context_name: String) -> Self {
+ Self { context_name }
+ }
+
+ fn build_table(name: &str, is_active: bool, config: &ContextConfig) -> Table {
+ let mut table = Table::new();
+ table.set_header(vec!["Property", "Value"]);
+
+ let display_name = if is_active {
+ format!("{name}*")
+ } else {
+ name.to_string()
+ };
+ table.add_row(vec!["Name", &display_name]);
+
+ 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]);
+ }
+
+ table
+ }
+}
+
+#[async_trait]
+impl CliCommand for ShowContextCmd {
+ fn explain(&self) -> String {
+ format!("show context \"{}\"", self.context_name)
Review Comment:
Switched to unquoted `format!("show context {context_name}")` to match siblings
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@iggy.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(cli): add context show and session status commands [iggy]
Posted by "hubcio (via GitHub)" <gi...@apache.org>.
hubcio merged PR #3096:
URL: https://github.com/apache/iggy/pull/3096
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@iggy.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(cli): add context show and session status commands [iggy]
Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #3096:
URL: https://github.com/apache/iggy/pull/3096#issuecomment-4226538452
## [Codecov](https://app.codecov.io/gh/apache/iggy/pull/3096?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:x: Patch coverage is `46.57534%` with `39 lines` in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 61.23%. Comparing base ([`27f0f11`](https://app.codecov.io/gh/apache/iggy/commit/27f0f11c65f5289bda2f67d9cf95526a87121aa3?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`9ebef6a`](https://app.codecov.io/gh/apache/iggy/commit/9ebef6afe65d38565361ce27f54491955e9b66c9?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
| [Files with missing lines](https://app.codecov.io/gh/apache/iggy/pull/3096?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
|---|---|---|
| [...re/cli/src/commands/binary\_context/show\_context.rs](https://app.codecov.io/gh/apache/iggy/pull/3096?src=pr&el=tree&filepath=core%2Fcli%2Fsrc%2Fcommands%2Fbinary_context%2Fshow_context.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Y29yZS9jbGkvc3JjL2NvbW1hbmRzL2JpbmFyeV9jb250ZXh0L3Nob3dfY29udGV4dC5ycw==) | 64.00% | [5 Missing and 13 partials :warning: ](https://app.codecov.io/gh/apache/iggy/pull/3096?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [...e/cli/src/commands/binary\_system/session\_status.rs](https://app.codecov.io/gh/apache/iggy/pull/3096?src=pr&el=tree&filepath=core%2Fcli%2Fsrc%2Fcommands%2Fbinary_system%2Fsession_status.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Y29yZS9jbGkvc3JjL2NvbW1hbmRzL2JpbmFyeV9zeXN0ZW0vc2Vzc2lvbl9zdGF0dXMucnM=) | 0.00% | [16 Missing :warning: ](https://app.codecov.io/gh/apache/iggy/pull/3096?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [core/cli/src/main.rs](https://app.codecov.io/gh/apache/iggy/pull/3096?src=pr&el=tree&filepath=core%2Fcli%2Fsrc%2Fmain.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Y29yZS9jbGkvc3JjL21haW4ucnM=) | 28.57% | [5 Missing :warning: ](https://app.codecov.io/gh/apache/iggy/pull/3096?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## master #3096 +/- ##
=============================================
- Coverage 72.71% 61.23% -11.49%
Complexity 943 943
=============================================
Files 1117 1119 +2
Lines 96285 96358 +73
Branches 73485 73558 +73
=============================================
- Hits 70014 59003 -11011
- Misses 23725 34871 +11146
+ Partials 2546 2484 -62
```
| [Components](https://app.codecov.io/gh/apache/iggy/pull/3096/components?src=pr&el=components&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
|---|---|---|
| [Rust Core](https://app.codecov.io/gh/apache/iggy/pull/3096/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `58.22% <46.57%> (-15.24%)` | :arrow_down: |
| [Java SDK](https://app.codecov.io/gh/apache/iggy/pull/3096/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `62.30% <ø> (ø)` | |
| [C# SDK](https://app.codecov.io/gh/apache/iggy/pull/3096/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `69.40% <ø> (ø)` | |
| [Python SDK](https://app.codecov.io/gh/apache/iggy/pull/3096/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `81.43% <ø> (ø)` | |
| [Node SDK](https://app.codecov.io/gh/apache/iggy/pull/3096/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `91.53% <ø> (ø)` | |
| [Go SDK](https://app.codecov.io/gh/apache/iggy/pull/3096/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `38.97% <ø> (ø)` | |
| [Files with missing lines](https://app.codecov.io/gh/apache/iggy/pull/3096?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
|---|---|---|
| [core/cli/src/args/context.rs](https://app.codecov.io/gh/apache/iggy/pull/3096?src=pr&el=tree&filepath=core%2Fcli%2Fsrc%2Fargs%2Fcontext.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Y29yZS9jbGkvc3JjL2FyZ3MvY29udGV4dC5ycw==) | `27.41% <ø> (-72.59%)` | :arrow_down: |
| [core/cli/src/args/mod.rs](https://app.codecov.io/gh/apache/iggy/pull/3096?src=pr&el=tree&filepath=core%2Fcli%2Fsrc%2Fargs%2Fmod.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Y29yZS9jbGkvc3JjL2FyZ3MvbW9kLnJz) | `38.09% <ø> (-40.48%)` | :arrow_down: |
| [core/cli/src/main.rs](https://app.codecov.io/gh/apache/iggy/pull/3096?src=pr&el=tree&filepath=core%2Fcli%2Fsrc%2Fmain.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Y29yZS9jbGkvc3JjL21haW4ucnM=) | `62.81% <28.57%> (-29.41%)` | :arrow_down: |
| [...e/cli/src/commands/binary\_system/session\_status.rs](https://app.codecov.io/gh/apache/iggy/pull/3096?src=pr&el=tree&filepath=core%2Fcli%2Fsrc%2Fcommands%2Fbinary_system%2Fsession_status.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Y29yZS9jbGkvc3JjL2NvbW1hbmRzL2JpbmFyeV9zeXN0ZW0vc2Vzc2lvbl9zdGF0dXMucnM=) | `0.00% <0.00%> (ø)` | |
| [...re/cli/src/commands/binary\_context/show\_context.rs](https://app.codecov.io/gh/apache/iggy/pull/3096?src=pr&el=tree&filepath=core%2Fcli%2Fsrc%2Fcommands%2Fbinary_context%2Fshow_context.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Y29yZS9jbGkvc3JjL2NvbW1hbmRzL2JpbmFyeV9jb250ZXh0L3Nob3dfY29udGV4dC5ycw==) | `64.00% <64.00%> (ø)` | |
... and [278 files with indirect coverage changes](https://app.codecov.io/gh/apache/iggy/pull/3096/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
</details>
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
- :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@iggy.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(cli): add context show and session status commands [iggy]
Posted by "hubcio (via GitHub)" <gi...@apache.org>.
hubcio commented on code in PR #3096:
URL: https://github.com/apache/iggy/pull/3096#discussion_r3161316503
##########
core/cli/src/commands/binary_system/session_status.rs:
##########
@@ -0,0 +1,70 @@
+/* Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use crate::commands::binary_system::session::ServerSession;
+use crate::commands::cli_command::{CliCommand, PRINT_TARGET};
+use async_trait::async_trait;
+use comfy_table::Table;
+use iggy_common::Client;
+use tracing::{Level, event};
+
+pub struct SessionStatusCmd {
+ server_session: ServerSession,
+}
+
+impl SessionStatusCmd {
+ pub fn new(server_address: String) -> Self {
+ Self {
+ server_session: ServerSession::new(server_address),
+ }
+ }
+}
+
+#[async_trait]
+impl CliCommand for SessionStatusCmd {
+ fn explain(&self) -> String {
+ "session status command".to_owned()
+ }
+
+ fn login_required(&self) -> bool {
+ false
+ }
+
+ fn connection_required(&self) -> bool {
+ false
+ }
+
+ async fn execute_cmd(&mut self, _client: &dyn Client) -> anyhow::Result<(), anyhow::Error> {
+ let is_active = self.server_session.is_active();
+ let server_address = self.server_session.get_server_address();
+
+ let mut table = Table::new();
+ table.set_header(vec!["Property", "Value"]);
+ table.add_row(vec!["Server Address", server_address]);
+
+ if is_active {
+ table.add_row(vec!["Session Active", "Yes"]);
+ } else {
+ table.add_row(vec!["Session Active", "No"]);
+ }
+
+ event!(target: PRINT_TARGET, Level::INFO, "{table}");
+
+ Ok(())
+ }
+}
Review Comment:
same gap as `show_context.rs` - no unit tests for `explain` / `login_required` / `connection_required`. mirror `delete_context.rs:67-83`.
##########
core/cli/src/commands/binary_context/show_context.rs:
##########
@@ -0,0 +1,114 @@
+/* Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use anyhow::bail;
+use async_trait::async_trait;
+use comfy_table::Table;
+use tracing::{Level, event};
+
+use crate::commands::cli_command::{CliCommand, PRINT_TARGET};
+use iggy_common::Client;
+
+use super::common::{ContextConfig, ContextManager};
+
+const MASKED_VALUE: &str = "********";
+
+pub struct ShowContextCmd {
+ context_name: String,
+}
+
+impl ShowContextCmd {
+ pub fn new(context_name: String) -> Self {
+ Self { context_name }
+ }
+
+ fn build_table(name: &str, is_active: bool, config: &ContextConfig) -> Table {
+ let mut table = Table::new();
+ table.set_header(vec!["Property", "Value"]);
+
+ let display_name = if is_active {
+ format!("{name}*")
+ } else {
+ name.to_string()
+ };
+ table.add_row(vec!["Name", &display_name]);
+
+ 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]);
+ }
+
+ table
+ }
+}
+
+#[async_trait]
+impl CliCommand for ShowContextCmd {
+ fn explain(&self) -> String {
+ format!("show context \"{}\"", self.context_name)
+ }
+
+ fn login_required(&self) -> bool {
+ false
+ }
+
+ fn connection_required(&self) -> bool {
+ false
+ }
+
+ async fn execute_cmd(&mut self, _client: &dyn Client) -> anyhow::Result<(), anyhow::Error> {
+ let mut context_mgr = ContextManager::default();
+ let contexts_map = context_mgr.get_contexts().await?;
+ let active_context_key = context_mgr.get_active_context_key().await?;
+
+ let config = match contexts_map.get(&self.context_name) {
+ Some(config) => config,
+ None => bail!("context '{}' not found", self.context_name),
+ };
+
+ let is_active = self.context_name == active_context_key;
+ let table = Self::build_table(&self.context_name, is_active, config);
+
+ event!(target: PRINT_TARGET, Level::INFO, "{table}");
+
+ Ok(())
+ }
+}
Review Comment:
missing tests covering `explain` / `login_required` / `connection_required`. sibling `delete_context.rs:67-83` has the pattern.
##########
core/cli/src/commands/binary_context/show_context.rs:
##########
@@ -0,0 +1,114 @@
+/* Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use anyhow::bail;
+use async_trait::async_trait;
+use comfy_table::Table;
+use tracing::{Level, event};
+
+use crate::commands::cli_command::{CliCommand, PRINT_TARGET};
+use iggy_common::Client;
+
+use super::common::{ContextConfig, ContextManager};
+
+const MASKED_VALUE: &str = "********";
+
+pub struct ShowContextCmd {
+ context_name: String,
+}
+
+impl ShowContextCmd {
+ pub fn new(context_name: String) -> Self {
+ Self { context_name }
+ }
+
+ fn build_table(name: &str, is_active: bool, config: &ContextConfig) -> Table {
+ let mut table = Table::new();
+ table.set_header(vec!["Property", "Value"]);
+
+ let display_name = if is_active {
+ format!("{name}*")
+ } else {
+ name.to_string()
+ };
+ table.add_row(vec!["Name", &display_name]);
+
+ 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]);
+ }
Review 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.
##########
core/cli/src/commands/binary_context/show_context.rs:
##########
@@ -0,0 +1,114 @@
+/* Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use anyhow::bail;
+use async_trait::async_trait;
+use comfy_table::Table;
+use tracing::{Level, event};
+
+use crate::commands::cli_command::{CliCommand, PRINT_TARGET};
+use iggy_common::Client;
+
+use super::common::{ContextConfig, ContextManager};
+
+const MASKED_VALUE: &str = "********";
+
+pub struct ShowContextCmd {
+ context_name: String,
+}
+
+impl ShowContextCmd {
+ pub fn new(context_name: String) -> Self {
+ Self { context_name }
+ }
+
+ fn build_table(name: &str, is_active: bool, config: &ContextConfig) -> Table {
+ let mut table = Table::new();
+ table.set_header(vec!["Property", "Value"]);
+
+ let display_name = if is_active {
+ format!("{name}*")
+ } else {
+ name.to_string()
+ };
+ table.add_row(vec!["Name", &display_name]);
+
+ 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]);
+ }
+
+ table
+ }
+}
+
+#[async_trait]
+impl CliCommand for ShowContextCmd {
+ fn explain(&self) -> String {
+ format!("show context \"{}\"", self.context_name)
Review 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.
##########
core/cli/src/commands/binary_system/session_status.rs:
##########
@@ -0,0 +1,70 @@
+/* Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use crate::commands::binary_system::session::ServerSession;
+use crate::commands::cli_command::{CliCommand, PRINT_TARGET};
+use async_trait::async_trait;
+use comfy_table::Table;
+use iggy_common::Client;
+use tracing::{Level, event};
+
+pub struct SessionStatusCmd {
+ server_session: ServerSession,
+}
+
+impl SessionStatusCmd {
+ pub fn new(server_address: String) -> Self {
+ Self {
+ server_session: ServerSession::new(server_address),
+ }
+ }
+}
+
+#[async_trait]
+impl CliCommand for SessionStatusCmd {
+ fn explain(&self) -> String {
+ "session status command".to_owned()
+ }
+
+ fn login_required(&self) -> bool {
+ false
+ }
+
+ fn connection_required(&self) -> bool {
+ false
+ }
+
+ async fn execute_cmd(&mut self, _client: &dyn Client) -> anyhow::Result<(), anyhow::Error> {
+ let is_active = self.server_session.is_active();
Review 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.
##########
core/integration/tests/cli/context/test_context_show_command.rs:
##########
@@ -0,0 +1,274 @@
+/* Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use std::collections::BTreeMap;
+
+use crate::cli::common::{
+ CLAP_INDENT, IggyCmdCommand, IggyCmdTest, IggyCmdTestCase, TestHelpCmd, USAGE_PREFIX,
+};
+use assert_cmd::assert::Assert;
+use async_trait::async_trait;
+use iggy::prelude::Client;
+use iggy_cli::commands::binary_context::common::ContextConfig;
+use iggy_common::ArgsOptional;
+use predicates::str::contains;
+use serial_test::parallel;
+
+use super::common::TestIggyContext;
+
+struct TestContextShowCmd {
+ test_iggy_context: TestIggyContext,
+ context_to_show: String,
+ expected_fields: Vec<(String, String)>,
+}
+
+impl TestContextShowCmd {
+ fn new(
+ test_iggy_context: TestIggyContext,
+ context_to_show: String,
+ expected_fields: Vec<(String, String)>,
+ ) -> Self {
+ Self {
+ test_iggy_context,
+ context_to_show,
+ expected_fields,
+ }
+ }
+}
+
+#[async_trait]
+impl IggyCmdTestCase for TestContextShowCmd {
+ async fn prepare_server_state(&mut self, _client: &dyn Client) {
+ self.test_iggy_context.prepare().await;
+ }
+
+ fn get_command(&self) -> IggyCmdCommand {
+ IggyCmdCommand::new()
+ .env(
+ "IGGY_HOME",
+ self.test_iggy_context.get_iggy_home().to_str().unwrap(),
+ )
+ .arg("context")
+ .arg("show")
+ .arg(self.context_to_show.clone())
+ .with_env_credentials()
+ }
+
+ fn verify_command(&self, command_state: Assert) {
+ let mut command_state = command_state.success();
+
+ for (key, value) in &self.expected_fields {
+ command_state = command_state
+ .stdout(contains(key.as_str()))
+ .stdout(contains(value.as_str()));
+ }
Review 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"`.
##########
core/cli/src/commands/binary_system/session_status.rs:
##########
@@ -0,0 +1,70 @@
+/* Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use crate::commands::binary_system::session::ServerSession;
+use crate::commands::cli_command::{CliCommand, PRINT_TARGET};
+use async_trait::async_trait;
+use comfy_table::Table;
+use iggy_common::Client;
+use tracing::{Level, event};
+
+pub struct SessionStatusCmd {
+ server_session: ServerSession,
+}
+
+impl SessionStatusCmd {
+ pub fn new(server_address: String) -> Self {
+ Self {
+ server_session: ServerSession::new(server_address),
+ }
+ }
+}
+
+#[async_trait]
+impl CliCommand for SessionStatusCmd {
+ fn explain(&self) -> String {
+ "session status command".to_owned()
+ }
+
+ fn login_required(&self) -> bool {
+ false
+ }
+
+ fn connection_required(&self) -> bool {
+ false
+ }
+
+ async fn execute_cmd(&mut self, _client: &dyn Client) -> anyhow::Result<(), anyhow::Error> {
+ let is_active = self.server_session.is_active();
+ let server_address = self.server_session.get_server_address();
+
+ let mut table = Table::new();
+ table.set_header(vec!["Property", "Value"]);
+ table.add_row(vec!["Server Address", server_address]);
+
+ if is_active {
+ table.add_row(vec!["Session Active", "Yes"]);
+ } else {
+ table.add_row(vec!["Session Active", "No"]);
+ }
Review Comment:
duplicates the `add_row` call. collapse to:
```rust
let active = if is_active { "Yes" } else { "No" };
table.add_row(vec!["Session Active", active]);
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@iggy.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(cli): add context show and session status commands [iggy]
Posted by "atharvalade (via GitHub)" <gi...@apache.org>.
atharvalade commented on code in PR #3096:
URL: https://github.com/apache/iggy/pull/3096#discussion_r3190974473
##########
core/cli/src/commands/binary_system/session_status.rs:
##########
@@ -0,0 +1,70 @@
+/* Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use crate::commands::binary_system::session::ServerSession;
+use crate::commands::cli_command::{CliCommand, PRINT_TARGET};
+use async_trait::async_trait;
+use comfy_table::Table;
+use iggy_common::Client;
+use tracing::{Level, event};
+
+pub struct SessionStatusCmd {
+ server_session: ServerSession,
+}
+
+impl SessionStatusCmd {
+ pub fn new(server_address: String) -> Self {
+ Self {
+ server_session: ServerSession::new(server_address),
+ }
+ }
+}
+
+#[async_trait]
+impl CliCommand for SessionStatusCmd {
+ fn explain(&self) -> String {
+ "session status command".to_owned()
+ }
+
+ fn login_required(&self) -> bool {
+ false
+ }
+
+ fn connection_required(&self) -> bool {
+ false
+ }
+
+ async fn execute_cmd(&mut self, _client: &dyn Client) -> anyhow::Result<(), anyhow::Error> {
+ let is_active = self.server_session.is_active();
Review Comment:
Output now shows` "Yes (token presence only, freshness not verified)"`. doc comments recommends `Iggy me `for server-side check
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@iggy.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(cli): add context show and session status commands [iggy]
Posted by "atharvalade (via GitHub)" <gi...@apache.org>.
atharvalade commented on code in PR #3096:
URL: https://github.com/apache/iggy/pull/3096#discussion_r3190963441
##########
core/cli/src/commands/binary_context/show_context.rs:
##########
@@ -0,0 +1,114 @@
+/* Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use anyhow::bail;
+use async_trait::async_trait;
+use comfy_table::Table;
+use tracing::{Level, event};
+
+use crate::commands::cli_command::{CliCommand, PRINT_TARGET};
+use iggy_common::Client;
+
+use super::common::{ContextConfig, ContextManager};
+
+const MASKED_VALUE: &str = "********";
+
+pub struct ShowContextCmd {
+ context_name: String,
+}
+
+impl ShowContextCmd {
+ pub fn new(context_name: String) -> Self {
+ Self { context_name }
+ }
+
+ fn build_table(name: &str, is_active: bool, config: &ContextConfig) -> Table {
+ let mut table = Table::new();
+ table.set_header(vec!["Property", "Value"]);
+
+ let display_name = if is_active {
+ format!("{name}*")
+ } else {
+ name.to_string()
+ };
+ table.add_row(vec!["Name", &display_name]);
+
+ 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]);
+ }
+
+ table
+ }
+}
+
+#[async_trait]
+impl CliCommand for ShowContextCmd {
+ fn explain(&self) -> String {
+ format!("show context \"{}\"", self.context_name)
+ }
+
+ fn login_required(&self) -> bool {
+ false
+ }
+
+ fn connection_required(&self) -> bool {
+ false
+ }
+
+ async fn execute_cmd(&mut self, _client: &dyn Client) -> anyhow::Result<(), anyhow::Error> {
+ let mut context_mgr = ContextManager::default();
+ let contexts_map = context_mgr.get_contexts().await?;
+ let active_context_key = context_mgr.get_active_context_key().await?;
+
+ let config = match contexts_map.get(&self.context_name) {
+ Some(config) => config,
+ None => bail!("context '{}' not found", self.context_name),
+ };
+
+ let is_active = self.context_name == active_context_key;
+ let table = Self::build_table(&self.context_name, is_active, config);
+
+ event!(target: PRINT_TARGET, Level::INFO, "{table}");
+
+ Ok(())
+ }
+}
Review Comment:
added unit tests
##########
core/cli/src/commands/binary_system/session_status.rs:
##########
@@ -0,0 +1,70 @@
+/* Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use crate::commands::binary_system::session::ServerSession;
+use crate::commands::cli_command::{CliCommand, PRINT_TARGET};
+use async_trait::async_trait;
+use comfy_table::Table;
+use iggy_common::Client;
+use tracing::{Level, event};
+
+pub struct SessionStatusCmd {
+ server_session: ServerSession,
+}
+
+impl SessionStatusCmd {
+ pub fn new(server_address: String) -> Self {
+ Self {
+ server_session: ServerSession::new(server_address),
+ }
+ }
+}
+
+#[async_trait]
+impl CliCommand for SessionStatusCmd {
+ fn explain(&self) -> String {
+ "session status command".to_owned()
+ }
+
+ fn login_required(&self) -> bool {
+ false
+ }
+
+ fn connection_required(&self) -> bool {
+ false
+ }
+
+ async fn execute_cmd(&mut self, _client: &dyn Client) -> anyhow::Result<(), anyhow::Error> {
+ let is_active = self.server_session.is_active();
+ let server_address = self.server_session.get_server_address();
+
+ let mut table = Table::new();
+ table.set_header(vec!["Property", "Value"]);
+ table.add_row(vec!["Server Address", server_address]);
+
+ if is_active {
+ table.add_row(vec!["Session Active", "Yes"]);
+ } else {
+ table.add_row(vec!["Session Active", "No"]);
+ }
+
+ event!(target: PRINT_TARGET, Level::INFO, "{table}");
+
+ Ok(())
+ }
+}
Review Comment:
added
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@iggy.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(cli): add context show and session status commands [iggy]
Posted by "atharvalade (via GitHub)" <gi...@apache.org>.
atharvalade commented on code in PR #3096:
URL: https://github.com/apache/iggy/pull/3096#discussion_r3190967538
##########
core/cli/src/commands/binary_context/show_context.rs:
##########
@@ -0,0 +1,114 @@
+/* Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use anyhow::bail;
+use async_trait::async_trait;
+use comfy_table::Table;
+use tracing::{Level, event};
+
+use crate::commands::cli_command::{CliCommand, PRINT_TARGET};
+use iggy_common::Client;
+
+use super::common::{ContextConfig, ContextManager};
+
+const MASKED_VALUE: &str = "********";
+
+pub struct ShowContextCmd {
+ context_name: String,
+}
+
+impl ShowContextCmd {
+ pub fn new(context_name: String) -> Self {
+ Self { context_name }
+ }
+
+ fn build_table(name: &str, is_active: bool, config: &ContextConfig) -> Table {
+ let mut table = Table::new();
+ table.set_header(vec!["Property", "Value"]);
+
+ let display_name = if is_active {
+ format!("{name}*")
+ } else {
+ name.to_string()
+ };
+ table.add_row(vec!["Name", &display_name]);
+
+ 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]);
+ }
Review Comment:
Now displays every `ArgsOptional` field, iterates `config.extra` for unknown TOML keys, and masks sensitive values.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@iggy.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(cli): add context show and session status commands [iggy]
Posted by "atharvalade (via GitHub)" <gi...@apache.org>.
atharvalade commented on code in PR #3096:
URL: https://github.com/apache/iggy/pull/3096#discussion_r3190976509
##########
core/integration/tests/cli/context/test_context_show_command.rs:
##########
@@ -0,0 +1,274 @@
+/* Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use std::collections::BTreeMap;
+
+use crate::cli::common::{
+ CLAP_INDENT, IggyCmdCommand, IggyCmdTest, IggyCmdTestCase, TestHelpCmd, USAGE_PREFIX,
+};
+use assert_cmd::assert::Assert;
+use async_trait::async_trait;
+use iggy::prelude::Client;
+use iggy_cli::commands::binary_context::common::ContextConfig;
+use iggy_common::ArgsOptional;
+use predicates::str::contains;
+use serial_test::parallel;
+
+use super::common::TestIggyContext;
+
+struct TestContextShowCmd {
+ test_iggy_context: TestIggyContext,
+ context_to_show: String,
+ expected_fields: Vec<(String, String)>,
+}
+
+impl TestContextShowCmd {
+ fn new(
+ test_iggy_context: TestIggyContext,
+ context_to_show: String,
+ expected_fields: Vec<(String, String)>,
+ ) -> Self {
+ Self {
+ test_iggy_context,
+ context_to_show,
+ expected_fields,
+ }
+ }
+}
+
+#[async_trait]
+impl IggyCmdTestCase for TestContextShowCmd {
+ async fn prepare_server_state(&mut self, _client: &dyn Client) {
+ self.test_iggy_context.prepare().await;
+ }
+
+ fn get_command(&self) -> IggyCmdCommand {
+ IggyCmdCommand::new()
+ .env(
+ "IGGY_HOME",
+ self.test_iggy_context.get_iggy_home().to_str().unwrap(),
+ )
+ .arg("context")
+ .arg("show")
+ .arg(self.context_to_show.clone())
+ .with_env_credentials()
+ }
+
+ fn verify_command(&self, command_state: Assert) {
+ let mut command_state = command_state.success();
+
+ for (key, value) in &self.expected_fields {
+ command_state = command_state
+ .stdout(contains(key.as_str()))
+ .stdout(contains(value.as_str()));
+ }
Review Comment:
changed to combined row substrings
##########
core/cli/src/commands/binary_system/session_status.rs:
##########
@@ -0,0 +1,70 @@
+/* Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use crate::commands::binary_system::session::ServerSession;
+use crate::commands::cli_command::{CliCommand, PRINT_TARGET};
+use async_trait::async_trait;
+use comfy_table::Table;
+use iggy_common::Client;
+use tracing::{Level, event};
+
+pub struct SessionStatusCmd {
+ server_session: ServerSession,
+}
+
+impl SessionStatusCmd {
+ pub fn new(server_address: String) -> Self {
+ Self {
+ server_session: ServerSession::new(server_address),
+ }
+ }
+}
+
+#[async_trait]
+impl CliCommand for SessionStatusCmd {
+ fn explain(&self) -> String {
+ "session status command".to_owned()
+ }
+
+ fn login_required(&self) -> bool {
+ false
+ }
+
+ fn connection_required(&self) -> bool {
+ false
+ }
+
+ async fn execute_cmd(&mut self, _client: &dyn Client) -> anyhow::Result<(), anyhow::Error> {
+ let is_active = self.server_session.is_active();
+ let server_address = self.server_session.get_server_address();
+
+ let mut table = Table::new();
+ table.set_header(vec!["Property", "Value"]);
+ table.add_row(vec!["Server Address", server_address]);
+
+ if is_active {
+ table.add_row(vec!["Session Active", "Yes"]);
+ } else {
+ table.add_row(vec!["Session Active", "No"]);
+ }
Review Comment:
collapsed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@iggy.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(cli): add context show and session status commands [iggy]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #3096:
URL: https://github.com/apache/iggy/pull/3096#issuecomment-4292791100
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!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@iggy.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org