Skip to content

Commit 05c0ec3

Browse files
committed
feat: formatting fix
1 parent 304b991 commit 05c0ec3

File tree

6 files changed

+24
-22
lines changed

6 files changed

+24
-22
lines changed

crates/chat-cli/src/cli/chat/consts.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ pub const AGENT_FORMAT_TOOLS_DOC_URL: &str =
2727
pub const AGENT_MIGRATION_DOC_URL: &str =
2828
"https://github.com/aws/amazon-q-developer-cli/blob/main/docs/legacy-profile-to-agent-migration.md";
2929

30-
3130
// The environment variable name where we set additional metadata for the AWS CLI user agent.
3231
pub const USER_AGENT_ENV_VAR: &str = "AWS_EXECUTION_ENV";
3332
pub const USER_AGENT_APP_NAME: &str = "AmazonQ-For-CLI";

crates/chat-cli/src/cli/chat/tools/execute/mod.rs

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use regex::Regex;
1010
use serde::Deserialize;
1111
use tracing::error;
1212

13+
use super::env_vars_with_user_agent;
1314
use crate::cli::agent::{
1415
Agent,
1516
PermissionEvalResult,
@@ -23,8 +24,6 @@ use crate::cli::chat::tools::{
2324
use crate::cli::chat::util::truncate_safe;
2425
use crate::os::Os;
2526

26-
use super::env_vars_with_user_agent;
27-
2827
// Platform-specific modules
2928
#[cfg(windows)]
3029
mod windows;
@@ -249,7 +248,6 @@ pub fn format_output(output: &str, max_size: usize) -> String {
249248
)
250249
}
251250

252-
253251
#[cfg(test)]
254252
mod tests {
255253
use super::*;
@@ -391,19 +389,22 @@ mod tests {
391389
#[tokio::test]
392390
async fn test_cloudtrail_tracking() {
393391
use crate::cli::chat::consts::{
394-
USER_AGENT_APP_NAME, USER_AGENT_ENV_VAR, USER_AGENT_VERSION_KEY, USER_AGENT_VERSION_VALUE,
392+
USER_AGENT_APP_NAME,
393+
USER_AGENT_ENV_VAR,
394+
USER_AGENT_VERSION_KEY,
395+
USER_AGENT_VERSION_VALUE,
395396
};
396-
397+
397398
let os = Os::new().await.unwrap();
398-
399+
399400
// Test that env_vars_with_user_agent sets the AWS_EXECUTION_ENV variable correctly
400401
let env_vars = env_vars_with_user_agent(&os);
401-
402+
402403
// Check that AWS_EXECUTION_ENV is set
403404
assert!(env_vars.contains_key(USER_AGENT_ENV_VAR));
404-
405+
405406
let user_agent_value = env_vars.get(USER_AGENT_ENV_VAR).unwrap();
406-
407+
407408
// Check the format is correct
408409
let expected_metadata = format!(
409410
"{} {}/{}",
@@ -415,19 +416,20 @@ mod tests {
415416
#[tokio::test]
416417
async fn test_cloudtrail_tracking_with_existing_env() {
417418
use crate::cli::chat::consts::{
418-
USER_AGENT_APP_NAME, USER_AGENT_ENV_VAR,
419+
USER_AGENT_APP_NAME,
420+
USER_AGENT_ENV_VAR,
419421
};
420-
422+
421423
let os = Os::new().await.unwrap();
422-
424+
423425
// Set an existing AWS_EXECUTION_ENV value (safe because Os uses in-memory hashmap in tests)
424426
unsafe {
425427
os.env.set_var(USER_AGENT_ENV_VAR, "ExistingValue");
426428
}
427-
429+
428430
let env_vars = env_vars_with_user_agent(&os);
429431
let user_agent_value = env_vars.get(USER_AGENT_ENV_VAR).unwrap();
430-
432+
431433
// Should contain both the existing value and our metadata
432434
assert!(user_agent_value.contains("ExistingValue"));
433435
assert!(user_agent_value.contains(USER_AGENT_APP_NAME));

crates/chat-cli/src/cli/chat/tools/execute/unix.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ use tracing::error;
1212

1313
use super::{
1414
CommandResult,
15-
format_output,
1615
env_vars_with_user_agent,
16+
format_output,
1717
};
1818
use crate::os::Os;
1919

crates/chat-cli/src/cli/chat/tools/execute/windows.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ use tracing::error;
1212

1313
use super::{
1414
CommandResult,
15-
format_output,
1615
env_vars_with_user_agent,
16+
format_output,
1717
};
1818
use crate::os::Os;
1919

@@ -30,7 +30,6 @@ pub async fn run_command<W: Write>(
3030
max_result_size: usize,
3131
mut updates: Option<W>,
3232
) -> Result<CommandResult> {
33-
3433
// Set up environment variables with user agent metadata for CloudTrail tracking
3534
let env_vars = env_vars_with_user_agent(os);
3635

crates/chat-cli/src/cli/chat/tools/mod.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ use tracing::error;
3838
use use_aws::UseAws;
3939

4040
use super::consts::{
41-
MAX_TOOL_RESPONSE_SIZE, USER_AGENT_APP_NAME, USER_AGENT_ENV_VAR, USER_AGENT_VERSION_KEY,
41+
MAX_TOOL_RESPONSE_SIZE,
42+
USER_AGENT_APP_NAME,
43+
USER_AGENT_ENV_VAR,
44+
USER_AGENT_VERSION_KEY,
4245
USER_AGENT_VERSION_VALUE,
4346
};
4447
use super::util::images::RichImageBlocks;
@@ -433,7 +436,7 @@ pub fn env_vars_with_user_agent(os: &Os) -> std::collections::HashMap<String, St
433436

434437
// Check if the user agent metadata env var already exists using Os
435438
let existing_value = os.env.get(USER_AGENT_ENV_VAR).ok();
436-
439+
437440
// If the user agent metadata env var already exists, append to it, otherwise set it
438441
if let Some(existing_value) = existing_value {
439442
if !existing_value.is_empty() {

crates/chat-cli/src/cli/chat/tools/use_aws.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,14 @@ use super::{
2222
InvokeOutput,
2323
MAX_TOOL_RESPONSE_SIZE,
2424
OutputKind,
25+
env_vars_with_user_agent,
2526
};
2627
use crate::cli::agent::{
2728
Agent,
2829
PermissionEvalResult,
2930
};
3031
use crate::os::Os;
3132

32-
use super::env_vars_with_user_agent;
33-
3433
const READONLY_OPS: [&str; 6] = ["get", "describe", "list", "ls", "search", "batch_get"];
3534

3635
// TODO: we should perhaps composite this struct with an interface that we can use to mock the

0 commit comments

Comments
 (0)