Skip to content

Commit ec11650

Browse files
committed
fix(cortex-cli): make export command exit code consistent with other commands
Fixes bounty issue #1550 The export command was using bail!() when no sessions were found, which results in exit code 1. Other commands like resume, sessions, and stats print a message and return Ok(()) for the same condition, resulting in exit code 0. This change makes export consistent with those commands.
1 parent 8f839ec commit ec11650

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

cortex-cli/src/export_cmd.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,10 @@ impl ExportCommand {
9696
// Get session ID - either from arg or interactive picker
9797
let session_id = match self.session_id {
9898
Some(id) => id,
99-
None => select_session(&cortex_home).await?,
99+
None => match select_session(&cortex_home).await? {
100+
Some(id) => id,
101+
None => return Ok(()),
102+
},
100103
};
101104

102105
// Parse conversation ID
@@ -159,11 +162,12 @@ impl ExportCommand {
159162
}
160163

161164
/// Select a session interactively.
162-
async fn select_session(cortex_home: &PathBuf) -> Result<String> {
165+
async fn select_session(cortex_home: &PathBuf) -> Result<Option<String>> {
163166
let sessions = list_sessions(cortex_home)?;
164167

165168
if sessions.is_empty() {
166-
bail!("No sessions found. Create a session first.");
169+
println!("No sessions found. Create a session first.");
170+
return Ok(None);
167171
}
168172

169173
// For non-interactive mode, just pick the most recent
@@ -193,7 +197,7 @@ async fn select_session(cortex_home: &PathBuf) -> Result<String> {
193197
}
194198

195199
println!("\nUsing most recent session: {}", sessions[0].id);
196-
Ok(sessions[0].id.clone())
200+
Ok(Some(sessions[0].id.clone()))
197201
}
198202

199203
/// Derive a title from the session content.

0 commit comments

Comments
 (0)