mirror of
https://github.com/nushell/nushell.git
synced 2025-05-31 07:08:22 +02:00
* WIP for moving nu-data out * Refactor nu-data out of nu-cli * Remove unwraps * Remove unwraps
38 lines
969 B
Rust
38 lines
969 B
Rust
use crate::commands::WholeStreamCommand;
|
|
use crate::prelude::*;
|
|
use crate::{CommandArgs, CommandRegistry, OutputStream};
|
|
use nu_errors::ShellError;
|
|
use nu_protocol::{ReturnSuccess, Signature, UntaggedValue};
|
|
|
|
pub struct Command;
|
|
|
|
#[async_trait]
|
|
impl WholeStreamCommand for Command {
|
|
fn name(&self) -> &str {
|
|
"config"
|
|
}
|
|
|
|
fn signature(&self) -> Signature {
|
|
Signature::build("config")
|
|
}
|
|
|
|
fn usage(&self) -> &str {
|
|
"Configuration management."
|
|
}
|
|
|
|
async fn run(
|
|
&self,
|
|
args: CommandArgs,
|
|
_registry: &CommandRegistry,
|
|
) -> Result<OutputStream, ShellError> {
|
|
let name_span = args.call_info.name_tag.clone();
|
|
let name = args.call_info.name_tag;
|
|
let result = nu_data::config::read(name_span, &None)?;
|
|
|
|
Ok(futures::stream::iter(vec![ReturnSuccess::value(
|
|
UntaggedValue::Row(result.into()).into_value(name),
|
|
)])
|
|
.to_output_stream())
|
|
}
|
|
}
|