Fix suggestions and run clippy

pull/395/head
Tom van Dijk 3 years ago committed by Arijit Basu
parent 44f05c6e4b
commit 102832c65c

@ -27,7 +27,7 @@ fn main() {
"$HOME/.config/xplr/init.lua")
-C, --extra-config <PATH>... Specifies extra config files to load
--on-load <MESSAGE>... Sends messages when xplr loads
--select <FILE> Selects the given paths.
--select <PATH>... Selects the given paths.
--force-focus Focuses the given path, instead of entering it."###;
let args = r###"

@ -1,5 +1,6 @@
use anyhow::Result;
use std::collections::VecDeque;
use std::io::{BufRead, BufReader};
use std::path::PathBuf;
use std::{env, io};
@ -79,7 +80,9 @@ impl Cli {
"--select" => {
while let Some(path) = args.pop_front() {
if path.starts_with('-') && path != "-" {
args.push_front(path);
for path in BufReader::new(std::io::stdin()).lines() {
cli.select.push(PathBuf::from(path?));
}
break;
} else {
cli.select.push(PathBuf::from(path));
@ -91,9 +94,9 @@ impl Cli {
let path = cli
.path
.as_ref()
.map(|x| x.clone())
.or(args.pop_front().map(PathBuf::from))
.unwrap_or(PathBuf::new());
.cloned()
.or_else(|| args.pop_front().map(PathBuf::from))
.unwrap_or_default();
cli.on_load.push(app::ExternalMsg::FocusPath(
path.to_string_lossy().to_string(),
));

@ -15,8 +15,6 @@ use crossterm::terminal as term;
use mlua::LuaSerdeExt;
use std::fs;
use std::io;
use std::io::BufRead;
use std::io::BufReader;
use std::io::Write;
use std::path::PathBuf;
use std::process::{Command, ExitStatus, Stdio};
@ -228,13 +226,7 @@ impl Runner {
// Select all files in our selection vector.
for file in self.select.iter() {
if file.as_os_str() == "-" {
for x in BufReader::new(std::io::stdin()).lines() {
app = app.select_path(x?)?;
}
} else {
app = app.select_path(file.to_string_lossy().to_string())?;
}
app = app.select_path(file.to_string_lossy().to_string())?;
}
'outer: for task in rx_msg_in {

Loading…
Cancel
Save