MCPcopy Create free account
hub / github.com/PerroEngine/Perro / new_animation_command

Function new_animation_command

perro_source/devtools/perro_cli/src/scaffold.rs:547–583  ·  view source on GitHub ↗
(args: &[String], cwd: &Path)

Source from the content-addressed store, hash-verified

545}
546
547pub(crate) fn new_animation_command(args: &[String], cwd: &Path) -> Result<(), String> {
548 let Some(raw_name) = parse_flag_value(args, "--name") else {
549 return Err("missing required flag `--name`".to_string());
550 };
551 let file_name = sanitize_animation_file_name(&raw_name)?;
552
553 let project_dir = if let Some(raw_project) = parse_flag_value(args, "--path") {
554 resolve_local_path(&raw_project, cwd)
555 } else {
556 find_project_root(cwd).ok_or_else(|| {
557 "could not find project.toml. Run from a project directory or pass --path <project_dir>."
558 .to_string()
559 })?
560 };
561 let project_dir = project_dir.canonicalize().unwrap_or(project_dir);
562 let content_root = resolve_content_root(&project_dir, args)?;
563 let content_prefix = resolve_content_prefix(args)?;
564
565 let target_dir = if let Some(raw_path) = parse_flag_value(args, "--res") {
566 resolve_res_subdir(&raw_path, &content_root, &content_prefix)?
567 } else {
568 content_root.join("animations")
569 };
570
571 let target_path = target_dir.join(file_name);
572 let animation_name = target_path
573 .file_stem()
574 .and_then(|s| s.to_str())
575 .unwrap_or("NewAnimation");
576 write_new_file(&target_path, &default_animation_panim(animation_name))?;
577 println!(
578 "created animation at {}",
579 normalize_powershell_path(&target_path)
580 );
581 maybe_open_file_in_editor(args, &target_path)?;
582 Ok(())
583}
584
585pub(crate) fn new_panimtree_command(args: &[String], cwd: &Path) -> Result<(), String> {
586 let Some(raw_name) = parse_flag_value(args, "--name") else {

Callers 1

mainFunction · 0.85

Calls 11

find_project_rootFunction · 0.85
resolve_content_rootFunction · 0.85
resolve_content_prefixFunction · 0.85
resolve_res_subdirFunction · 0.85
write_new_fileFunction · 0.85
joinMethod · 0.80
parse_flag_valueFunction · 0.70
resolve_local_pathFunction · 0.70
default_animation_panimFunction · 0.70

Tested by

no test coverage detected