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:
Eli Flanagan 2021-05-21 22:19:43 -04:00 committed by GitHub
parent cb90b90cbf
commit 2b92e3e8a7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -9,11 +9,6 @@ use nu_value_ext::as_string;
pub struct Command;
#[derive(Deserialize)]
pub struct Arguments {
grouper: Option<Value>,
}
impl WholeStreamCommand for Command {
fn name(&self) -> &str {
"group-by"
@ -131,9 +126,10 @@ enum Grouper {
pub fn group_by(args: CommandArgs) -> Result<OutputStream, ShellError> {
let name = args.call_info.name_tag.clone();
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 group_strategy = Grouper::ByColumn(None);