cratefmt alias
This commit is contained in:
		
							parent
							
								
									bc7c90245f
								
							
						
					
					
						commit
						d666330b67
					
				@ -69,4 +69,23 @@ _cdg() {
 | 
				
			|||||||
    _arguments "1: :($( cat $GCLONE_PATH/.cdgcache | rev | cut -d '/' -f 1 | rev))"
 | 
					    _arguments "1: :($( cat $GCLONE_PATH/.cdgcache | rev | cut -d '/' -f 1 | rev))"
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					cratefmt() {
 | 
				
			||||||
 | 
					    local current_dir=$PWD
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    # Find cargo.toml
 | 
				
			||||||
 | 
					    while [ ! -f Cargo.toml ] && [ $PWD != "/" ]; do
 | 
				
			||||||
 | 
					        cd ..
 | 
				
			||||||
 | 
					    done
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if [ -f Cargo.toml ]; then
 | 
				
			||||||
 | 
					        rustfmt --edition 2018 `find src -name "*.rs"`
 | 
				
			||||||
 | 
					    else
 | 
				
			||||||
 | 
					        echo -e "\033[1;31merror:\033[0m\033[1m can't find Cargo.toml\033[0m"
 | 
				
			||||||
 | 
					        cd $current_dir
 | 
				
			||||||
 | 
					        return 1
 | 
				
			||||||
 | 
					    fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    cd $current_dir
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
compdef _cdg cdg
 | 
					compdef _cdg cdg
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user