mirror of
https://github.com/nushell/nushell
synced 2024-12-27 21:43:09 +00:00
port group-by to engine-p (#3458)
* migrate group-by to engine p Part of #3390. * consume positional argument correctly
This commit is contained in:
parent
cb90b90cbf
commit
2b92e3e8a7
1 changed files with 3 additions and 7 deletions
|
@ -9,11 +9,6 @@ use nu_value_ext::as_string;
|
||||||
|
|
||||||
pub struct Command;
|
pub struct Command;
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
|
||||||
pub struct Arguments {
|
|
||||||
grouper: Option<Value>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl WholeStreamCommand for Command {
|
impl WholeStreamCommand for Command {
|
||||||
fn name(&self) -> &str {
|
fn name(&self) -> &str {
|
||||||
"group-by"
|
"group-by"
|
||||||
|
@ -131,9 +126,10 @@ enum Grouper {
|
||||||
pub fn group_by(args: CommandArgs) -> Result<OutputStream, ShellError> {
|
pub fn group_by(args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||||
let name = args.call_info.name_tag.clone();
|
let name = args.call_info.name_tag.clone();
|
||||||
let context = Arc::new(EvaluationContext::from_args(&args));
|
let context = Arc::new(EvaluationContext::from_args(&args));
|
||||||
let (Arguments { grouper }, input) = args.process()?;
|
let args = args.evaluate_once()?;
|
||||||
|
|
||||||
let values: Vec<Value> = input.collect();
|
let grouper = args.opt(0)?;
|
||||||
|
let values: Vec<Value> = args.input.collect();
|
||||||
let mut keys: Vec<Result<String, ShellError>> = vec![];
|
let mut keys: Vec<Result<String, ShellError>> = vec![];
|
||||||
let mut group_strategy = Grouper::ByColumn(None);
|
let mut group_strategy = Grouper::ByColumn(None);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue