mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 19:37:45 +02:00
Reduce unwraps
Remove a number of unwraps. In some cases, a `?` just worked as is. I also made it possible to use `?` to go from Result<OutputStream, ShellError> to OutputStream. Finally, started updating PerItemCommand to be able to use the signature deserialization logic, which substantially reduces unwraps. This is still in-progress work, but tests pass and it should be clear to merge and keep iterating on master.
This commit is contained in:
@ -7,12 +7,19 @@ use crate::shell::shell::Shell;
|
||||
use rustyline::completion::FilenameCompleter;
|
||||
use rustyline::hint::{Hinter, HistoryHinter};
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
pub struct FilesystemShell {
|
||||
crate path: String,
|
||||
completer: NuCompleter,
|
||||
hinter: HistoryHinter,
|
||||
}
|
||||
|
||||
impl std::fmt::Debug for FilesystemShell {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "FilesystemShell @ {}", self.path)
|
||||
}
|
||||
}
|
||||
|
||||
impl Clone for FilesystemShell {
|
||||
fn clone(&self) -> Self {
|
||||
FilesystemShell {
|
||||
|
@ -3,7 +3,7 @@ use crate::context::SourceMap;
|
||||
use crate::errors::ShellError;
|
||||
use crate::stream::OutputStream;
|
||||
|
||||
pub trait Shell {
|
||||
pub trait Shell: std::fmt::Debug {
|
||||
fn name(&self, source_map: &SourceMap) -> String;
|
||||
fn ls(&self, args: EvaluatedWholeStreamCommandArgs) -> Result<OutputStream, ShellError>;
|
||||
fn cd(&self, args: EvaluatedWholeStreamCommandArgs) -> Result<OutputStream, ShellError>;
|
||||
|
@ -7,7 +7,7 @@ use crate::stream::OutputStream;
|
||||
use std::error::Error;
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct ShellManager {
|
||||
crate shells: Arc<Mutex<Vec<Box<dyn Shell + Send>>>>,
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ use crate::shell::shell::Shell;
|
||||
use std::ffi::OsStr;
|
||||
use std::path::PathBuf;
|
||||
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct ValueShell {
|
||||
crate path: String,
|
||||
crate value: Tagged<Value>,
|
||||
|
Reference in New Issue
Block a user