Skip to content

Commit

Permalink
Merge pull request #39 from feddynventor/master
Browse files Browse the repository at this point in the history
basename flag added
  • Loading branch information
nik012003 committed Jan 15, 2024
2 parents aa4f1c9 + 810855c commit a78271f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
19 changes: 8 additions & 11 deletions src/list_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,20 +148,17 @@ fn setup_factory(factory: &SignalListItemFactory, list: &MultiSelection) {

// show either relative or absolute path
// This is safe because the file needs to exist
let str = if file_object
let str = if ARGS.get().unwrap().basename || file_object
.file()
.has_parent(Some(CURRENT_DIRECTORY.get().unwrap()))
{
CURRENT_DIRECTORY
.get()
.unwrap()
.relative_path(&file_object.file())
.expect("Can't make a relative path")
.to_str()
.expect("Couldn't read file name")
.has_parent(Some(CURRENT_DIRECTORY.get().unwrap())
) {
file_object.file()
.basename().unwrap()
.to_str().unwrap()
.to_string()
} else {
file_object.file().parse_name().to_string()
file_object.file()
.parse_name().to_string()
};

let label = Label::builder()
Expand Down
4 changes: 4 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ struct Cli {
/// Paths to the files you want to drag
#[arg(value_name = "PATH")]
paths: Vec<PathBuf>,

/// Always show basename of each file
#[arg(short = 'b', long)]
basename: bool,
}

// switch to Lazy Cell when it is stable.
Expand Down

0 comments on commit a78271f

Please sign in to comment.