@ -16,7 +16,7 @@ pub struct Args {
pub verbosity : u64 ,
pub verbosity : u64 ,
pub log_file : Option < PathBuf > ,
pub log_file : Option < PathBuf > ,
pub config_file : Option < PathBuf > ,
pub config_file : Option < PathBuf > ,
pub files : Vec < ( PathBuf , Position ) > ,
pub files : Vec < ( PathBuf , Option < Position > ) > ,
pub working_directory : Option < PathBuf > ,
pub working_directory : Option < PathBuf > ,
}
}
@ -106,7 +106,10 @@ impl Args {
if let Some ( file ) = args . files . first_mut ( ) {
if let Some ( file ) = args . files . first_mut ( ) {
if line_number ! = 0 {
if line_number ! = 0 {
file . 1. row = line_number ;
file . 1 = match file . 1 {
Some ( pos ) = > Some ( Position ::new ( line_number , pos . col ) ) ,
None = > Some ( Position ::new ( line_number , 0 ) ) ,
}
}
}
}
}
@ -115,8 +118,8 @@ impl Args {
}
}
/// Parse arg into [`PathBuf`] and position.
/// Parse arg into [`PathBuf`] and position.
pub ( crate ) fn parse_file ( s : & str ) -> ( PathBuf , Position ) {
pub ( crate ) fn parse_file ( s : & str ) -> ( PathBuf , Option < Position > ) {
let def = | | ( PathBuf ::from ( s ) , Position ::default ( ) ) ;
let def = | | ( PathBuf ::from ( s ) , None ) ;
if Path ::new ( s ) . exists ( ) {
if Path ::new ( s ) . exists ( ) {
return def ( ) ;
return def ( ) ;
}
}
@ -128,22 +131,22 @@ pub(crate) fn parse_file(s: &str) -> (PathBuf, Position) {
/// Split file.rs:10:2 into [`PathBuf`], row and col.
/// Split file.rs:10:2 into [`PathBuf`], row and col.
///
///
/// Does not validate if file.rs is a file or directory.
/// Does not validate if file.rs is a file or directory.
fn split_path_row_col ( s : & str ) -> Option < ( PathBuf , Position ) > {
fn split_path_row_col ( s : & str ) -> Option < ( PathBuf , Option < Position > ) > {
let mut s = s . rsplitn ( 3 , ':' ) ;
let mut s = s . rsplitn ( 3 , ':' ) ;
let col : usize = s . next ( ) ? . parse ( ) . ok ( ) ? ;
let col : usize = s . next ( ) ? . parse ( ) . ok ( ) ? ;
let row : usize = s . next ( ) ? . parse ( ) . ok ( ) ? ;
let row : usize = s . next ( ) ? . parse ( ) . ok ( ) ? ;
let path = s . next ( ) ? . into ( ) ;
let path = s . next ( ) ? . into ( ) ;
let pos = Position ::new ( row . saturating_sub ( 1 ) , col . saturating_sub ( 1 ) ) ;
let pos = Position ::new ( row . saturating_sub ( 1 ) , col . saturating_sub ( 1 ) ) ;
Some ( ( path , pos ) )
Some ( ( path , Some ( pos ) ) )
}
}
/// Split file.rs:10 into [`PathBuf`] and row.
/// Split file.rs:10 into [`PathBuf`] and row.
///
///
/// Does not validate if file.rs is a file or directory.
/// Does not validate if file.rs is a file or directory.
fn split_path_row ( s : & str ) -> Option < ( PathBuf , Position ) > {
fn split_path_row ( s : & str ) -> Option < ( PathBuf , Option < Position > ) > {
let ( path , row ) = s . rsplit_once ( ':' ) ? ;
let ( path , row ) = s . rsplit_once ( ':' ) ? ;
let row : usize = row . parse ( ) . ok ( ) ? ;
let row : usize = row . parse ( ) . ok ( ) ? ;
let path = path . into ( ) ;
let path = path . into ( ) ;
let pos = Position ::new ( row . saturating_sub ( 1 ) , 0 ) ;
let pos = Position ::new ( row . saturating_sub ( 1 ) , 0 ) ;
Some ( ( path , pos ) )
Some ( ( path , Some ( pos ) ) )
}
}