Skip to content

Commit 174fe72

Browse files
committed
redirecting qchat binary also. Also added a better warning message
1 parent 01d61c6 commit 174fe72

File tree

5 files changed

+42
-5
lines changed

5 files changed

+42
-5
lines changed

crates/fig_desktop/src/install.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,11 @@ pub async fn initialize_fig_dir(env: &fig_os_shim::Env) -> anyhow::Result<()> {
332332
if let Err(err) = fig_util::wrapper::create_q_wrapper(&local_bin).await {
333333
warn!(%err, "Failed to create q wrapper script");
334334
}
335+
} else if old_cli_binary_name == &"qchat" {
336+
// Create wrapper script for qchat that calls q chat
337+
if let Err(err) = fig_util::wrapper::create_qchat_wrapper(&local_bin).await {
338+
warn!(%err, "Failed to create qchat wrapper script");
339+
}
335340
} else if old_cli_binary_path.is_symlink() {
336341
// Handle other legacy binaries (cw) with symlinks
337342
if let Err(err) = symlink(&q_cli_path, &old_cli_binary_path).await {
@@ -668,7 +673,12 @@ async fn install_appimage_binaries(ctx: &Context) -> anyhow::Result<()> {
668673

669674
// Create q wrapper for backward compatibility
670675
if let Err(err) = fig_util::wrapper::create_q_wrapper(&home_local_bin_ctx(ctx)?).await {
671-
error!(%err, "Failed to create q wrapper script");
676+
warn!(%err, "Failed to create q wrapper script");
677+
}
678+
679+
// Create qchat wrapper for backward compatibility
680+
if let Err(err) = fig_util::wrapper::create_qchat_wrapper(&home_local_bin_ctx(ctx)?).await {
681+
warn!(%err, "Failed to create qchat wrapper script");
672682
}
673683

674684
Ok(())

crates/fig_install/src/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ pub async fn uninstall(components: InstallComponents, ctx: Arc<Context>) -> Resu
7272
// let folders = [directories::home_local_bin()?, Path::new("/usr/local/bin").into()];
7373
let folders = [directories::home_local_bin()?];
7474

75-
let mut all_binary_names = vec![CLI_BINARY_NAME, CHAT_BINARY_NAME, PTY_BINARY_NAME, "q"];
75+
let mut all_binary_names = vec![CLI_BINARY_NAME, CHAT_BINARY_NAME, PTY_BINARY_NAME, "q", "qchat"];
7676
all_binary_names.extend(OLD_CLI_BINARY_NAMES);
7777
all_binary_names.extend(OLD_PTY_BINARY_NAMES);
7878

crates/fig_util/src/consts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub const RUNTIME_DIR_NAME: &str = "cwrun";
2727

2828
// These are the old "CodeWhisperer" branding, used anywhere we will not update to Amazon Q
2929
pub const OLD_PRODUCT_NAME: &str = "CodeWhisperer";
30-
pub const OLD_CLI_BINARY_NAMES: &[&str] = &["cw", "q"];
30+
pub const OLD_CLI_BINARY_NAMES: &[&str] = &["cw", "q", "qchat"];
3131
pub const OLD_PTY_BINARY_NAMES: &[&str] = &["cwterm"];
3232

3333
pub const GITHUB_REPO_NAME: &str = "aws/amazon-q-developer-cli";

crates/fig_util/src/wrapper.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,33 @@ pub async fn create_q_wrapper(install_dir: &Path) -> Result<(), Error> {
4343
Ok(())
4444
}
4545

46+
/// Create legacy qchat wrapper script for backward compatibility
47+
pub async fn create_qchat_wrapper(install_dir: &Path) -> Result<(), Error> {
48+
let wrapper_path = install_dir.join("qchat");
49+
50+
// Remove existing qchat command if it exists
51+
if wrapper_path.exists() {
52+
tokio::fs::remove_file(&wrapper_path).await?;
53+
}
54+
55+
// Create wrapper script content that calls q chat
56+
let wrapper_content = format!("#!/bin/sh\n\"{}/q\" chat \"$@\"\n", install_dir.display());
57+
58+
// Write wrapper script
59+
tokio::fs::write(&wrapper_path, wrapper_content).await?;
60+
61+
// Make executable
62+
#[cfg(unix)]
63+
{
64+
use std::os::unix::fs::PermissionsExt;
65+
let mut perms = tokio::fs::metadata(&wrapper_path).await?.permissions();
66+
perms.set_mode(0o755);
67+
tokio::fs::set_permissions(&wrapper_path, perms).await?;
68+
}
69+
70+
Ok(())
71+
}
72+
4673
/// Check if the existing q command is our wrapper script
4774
async fn is_our_wrapper(path: &Path) -> Result<bool, Error> {
4875
if let Ok(content) = tokio::fs::read_to_string(path).await {

crates/q_cli/src/cli/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ use crate::util::{
9090
is_logged_in_check,
9191
};
9292

93-
const LEGACY_WARNING: &str = "Warn: Q CLI is now Kiro CLI and should be invoked as kiro-cli rather than q";
93+
const LEGACY_WARNING: &str = "Warning! Q CLI is now Kiro CLI and should be invoked as kiro-cli rather than q";
9494

9595
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, ValueEnum)]
9696
pub enum OutputFormat {
@@ -304,7 +304,7 @@ impl Cli {
304304
pub async fn execute(self) -> Result<ExitCode> {
305305
// Show legacy warning if flag is set
306306
if self.show_legacy_warning {
307-
eprintln!("{}", LEGACY_WARNING);
307+
eprintln!("\x1b[33m{}\x1b[0m", LEGACY_WARNING);
308308
}
309309

310310
// Initialize our logger and keep around the guard so logging can perform as expected.

0 commit comments

Comments
 (0)