MCPcopy Create free account
hub / github.com/c4pt0r/pie / run_session_cli_command

Function run_session_cli_command

crates/coding-agent/src/main.rs:250–375  ·  view source on GitHub ↗
(
    command: &SessionCliCommand,
    repo: &JsonlSessionRepo,
    cwd: &std::path::Path,
)

Source from the content-addressed store, hash-verified

248}
249
250async fn run_session_cli_command(
251 command: &SessionCliCommand,
252 repo: &JsonlSessionRepo,
253 cwd: &std::path::Path,
254) -> Result<()> {
255 match command {
256 SessionCliCommand::Export {
257 session,
258 current: _,
259 output,
260 exclude_triggers,
261 } => {
262 let session_path = if let Some(id) = session {
263 session::find_path_by_id(repo, id)
264 .await?
265 .with_context(|| format!("no session matches id {id}"))?
266 } else {
267 session::newest_path(repo).await?.with_context(|| {
268 format!("no sessions to export in {}", repo.root().display())
269 })?
270 };
271 let session = repo.open(&session_path).await?;
272 let metadata = session.storage().get_metadata_json().await?;
273 let session_id = metadata
274 .get("id")
275 .and_then(|v| v.as_str())
276 .unwrap_or_else(|| {
277 session_path
278 .file_stem()
279 .and_then(|s| s.to_str())
280 .unwrap_or("session")
281 });
282 let output_path = output
283 .clone()
284 .unwrap_or_else(|| session_archive::default_export_path(cwd, session_id));
285 let output_path = if output_path.is_absolute() {
286 output_path
287 } else {
288 cwd.join(output_path)
289 };
290 print_session_archive_warning();
291 let summary =
292 session_archive::export_session(&session_path, &output_path, *exclude_triggers)
293 .await?;
294 println!(
295 "exported session archive: {}",
296 summary.output_path.display()
297 );
298 println!(
299 "session {} entries={} triggers={} cron={}",
300 short_id(&summary.session_id),
301 summary.entry_count,
302 yes_no(summary.has_triggers),
303 yes_no(summary.has_cron)
304 );
305 Ok(())
306 }
307 SessionCliCommand::Import {

Callers 2

run_cli_commandFunction · 0.85

Calls 15

find_path_by_idFunction · 0.85
newest_pathFunction · 0.85
export_sessionFunction · 0.85
import_sessionFunction · 0.85
activate_importedFunction · 0.85
storageMethod · 0.80
default_export_pathFunction · 0.70
getMethod · 0.65
openMethod · 0.45
get_metadata_jsonMethod · 0.45
as_strMethod · 0.45

Tested by

no test coverage detected