use std::path::{ Path, PathBuf };
use crate::artifact::ArtifactKind;
pub use crate::error::AssetPathsError;
#[ derive( Debug, Clone ) ]
pub struct AssetPaths
{
source_root : PathBuf,
target_root : PathBuf,
}
impl AssetPaths
{
#[ inline ]
pub fn from_env() -> Result< Self, AssetPathsError >
{
let source_root = if let Ok( v ) = std::env::var( "PRO_CLAUDE" )
{
PathBuf::from( v )
}
else
{
return Err( AssetPathsError::EnvVarNotSet );
};
let target_root = std::env::current_dir().unwrap_or_else( |_| PathBuf::from( "." ) );
Ok( Self { source_root, target_root } )
}
#[ must_use ]
#[ inline ]
pub fn new( source_root : PathBuf, target_root : PathBuf ) -> Self
{
Self { source_root, target_root }
}
#[ must_use ]
#[ inline ]
pub fn source_dir( &self, kind : ArtifactKind ) -> PathBuf
{
self.source_root.join( kind.source_subdir() )
}
#[ must_use ]
#[ inline ]
pub fn target_dir( &self, kind : ArtifactKind ) -> PathBuf
{
self.target_root.join( ".claude" ).join( kind.target_subdir() )
}
#[ must_use ]
#[ inline ]
pub fn source_root( &self ) -> &Path
{
&self.source_root
}
}