fix fmt cli
This commit is contained in:
		
							parent
							
								
									8a71abef2e
								
							
						
					
					
						commit
						1ef79a0faf
					
				
					 3 changed files with 11 additions and 9 deletions
				
			
		| 
						 | 
				
			
			@ -146,16 +146,17 @@ pub fn fix_file_cli(fix_args: FixArgs, root: &dyn Dir) -> anyhow::Result<Edit> {
 | 
			
		|||
    let mut treehouse = Treehouse::new();
 | 
			
		||||
    let mut diagnostics = vec![];
 | 
			
		||||
    let file_id = treehouse.add_file(fix_args.file.clone(), Source::Other(file));
 | 
			
		||||
    let edit_path = vfs::query::<EditPath>(root, &fix_args.file).ok_or_else(|| {
 | 
			
		||||
        anyhow!(
 | 
			
		||||
            "{} is not an editable file (perhaps it is not in a persistent path?)",
 | 
			
		||||
            fix_args.file
 | 
			
		||||
        )
 | 
			
		||||
    })?;
 | 
			
		||||
 | 
			
		||||
    Ok(
 | 
			
		||||
        if let Ok(fixed) = fix_file(&mut treehouse, &mut diagnostics, file_id) {
 | 
			
		||||
            if fix_args.apply {
 | 
			
		||||
                let edit_path = vfs::query::<EditPath>(root, &fix_args.file).ok_or_else(|| {
 | 
			
		||||
                    anyhow!(
 | 
			
		||||
                        "{} is not an editable file (perhaps it is not in a persistent path?)",
 | 
			
		||||
                        fix_args.file
 | 
			
		||||
                    )
 | 
			
		||||
                })?;
 | 
			
		||||
 | 
			
		||||
                // Try to write the backup first. If writing that fails, bail out without overwriting
 | 
			
		||||
                // the source file.
 | 
			
		||||
                if let Some(backup_path) = fix_args.backup {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -92,7 +92,7 @@ async fn fallible_main(
 | 
			
		|||
            serve(sources, dirs, AsyncDir::new(target), serve_args.port).await?;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        Command::Fix(fix_args) => fix_file_cli(fix_args, &*dirs.content)?.apply().await?,
 | 
			
		||||
        Command::Fix(fix_args) => fix_file_cli(fix_args, &*dirs.root)?.apply().await?,
 | 
			
		||||
        Command::FixAll(fix_args) => fix_all_cli(fix_args, &*dirs.content)?.apply().await?,
 | 
			
		||||
 | 
			
		||||
        Command::Wc(wc_args) => wc_cli(&dirs.content, wc_args)?,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -59,8 +59,9 @@ impl PhysicalDir {
 | 
			
		|||
 | 
			
		||||
    #[instrument("PhysicalDir::content", skip(self))]
 | 
			
		||||
    fn content(&self, path: &VPath) -> Option<Content> {
 | 
			
		||||
        std::fs::read(self.root.join(physical_path(path)))
 | 
			
		||||
            .inspect_err(|err| error!("{self:?} cannot read file at vpath {path:?}: {err:?}",))
 | 
			
		||||
        let physical_path = self.root.join(physical_path(path));
 | 
			
		||||
        std::fs::read(&physical_path)
 | 
			
		||||
            .inspect_err(|err| error!("{self:?} cannot read file at vpath {path:?} / physical {physical_path:?}: {err:?}",))
 | 
			
		||||
            .ok()
 | 
			
		||||
            .map(|bytes| {
 | 
			
		||||
                Content::new(
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue