nushell/src/commands.rs

177 lines
4.5 KiB
Rust
Raw Normal View History

#[macro_use]
pub(crate) mod macros;
2019-10-30 07:54:06 +01:00
pub(crate) mod append;
pub(crate) mod args;
pub(crate) mod autoview;
pub(crate) mod cd;
pub(crate) mod classified;
pub(crate) mod clip;
pub(crate) mod command;
pub(crate) mod config;
2019-10-15 12:19:06 +02:00
pub(crate) mod count;
pub(crate) mod cp;
pub(crate) mod date;
pub(crate) mod debug;
2019-09-08 01:43:53 +02:00
pub(crate) mod echo;
pub(crate) mod enter;
2019-09-16 09:52:58 +02:00
pub(crate) mod env;
pub(crate) mod exit;
2019-09-03 08:04:46 +02:00
pub(crate) mod fetch;
pub(crate) mod first;
pub(crate) mod from_bson;
pub(crate) mod from_csv;
pub(crate) mod from_ini;
pub(crate) mod from_json;
2019-08-27 23:45:18 +02:00
pub(crate) mod from_sqlite;
2019-10-13 21:15:30 +02:00
pub(crate) mod from_ssv;
pub(crate) mod from_toml;
pub(crate) mod from_tsv;
2019-09-19 06:25:29 +02:00
pub(crate) mod from_url;
pub(crate) mod from_xml;
pub(crate) mod from_yaml;
pub(crate) mod get;
2019-10-21 01:42:07 +02:00
pub(crate) mod group_by;
pub(crate) mod help;
pub(crate) mod history;
pub(crate) mod last;
pub(crate) mod lines;
pub(crate) mod ls;
pub(crate) mod mkdir;
pub(crate) mod mv;
pub(crate) mod next;
pub(crate) mod nth;
pub(crate) mod open;
pub(crate) mod pick;
2019-09-17 09:07:11 +02:00
pub(crate) mod pivot;
pub(crate) mod plugin;
2019-08-30 20:27:15 +02:00
pub(crate) mod post;
2019-10-30 07:54:06 +01:00
pub(crate) mod prepend;
pub(crate) mod prev;
2019-09-07 17:49:15 +02:00
pub(crate) mod pwd;
pub(crate) mod reject;
pub(crate) mod reverse;
pub(crate) mod rm;
pub(crate) mod save;
pub(crate) mod shells;
pub(crate) mod size;
pub(crate) mod skip_while;
pub(crate) mod sort_by;
2019-11-03 22:36:47 +01:00
2019-11-04 02:55:34 +01:00
cfg_if::cfg_if! {
if #[cfg(data_processing_primitives)] {
pub(crate) mod split_by;
pub(crate) mod reduce_by;
2019-11-12 08:07:43 +01:00
pub(crate) mod evaluate_by;
pub(crate) mod t_sort_by;
pub(crate) mod map_max_by;
pub(crate) mod histogram;
2019-11-04 02:55:34 +01:00
}
}
2019-11-03 22:36:47 +01:00
pub(crate) mod split_column;
pub(crate) mod split_row;
pub(crate) mod table;
pub(crate) mod tags;
pub(crate) mod to_bson;
pub(crate) mod to_csv;
pub(crate) mod to_json;
2019-08-27 23:45:18 +02:00
pub(crate) mod to_sqlite;
pub(crate) mod to_toml;
pub(crate) mod to_tsv;
2019-09-19 06:25:29 +02:00
pub(crate) mod to_url;
pub(crate) mod to_yaml;
pub(crate) mod trim;
pub(crate) mod version;
pub(crate) mod where_;
pub(crate) mod which_;
pub(crate) use autoview::Autoview;
pub(crate) use cd::CD;
pub(crate) use command::{
2019-08-23 05:29:08 +02:00
per_item_command, whole_stream_command, Command, PerItemCommand, RawCommandArgs,
UnevaluatedCallInfo, WholeStreamCommand,
2019-08-02 21:15:07 +02:00
};
2019-08-27 23:45:18 +02:00
2019-10-30 07:54:06 +01:00
pub(crate) use append::Append;
Overhaul the expansion system The main thrust of this (very large) commit is an overhaul of the expansion system. The parsing pipeline is: - Lightly parse the source file for atoms, basic delimiters and pipeline structure into a token tree - Expand the token tree into a HIR (high-level intermediate representation) based upon the baseline syntax rules for expressions and the syntactic shape of commands. Somewhat non-traditionally, nu doesn't have an AST at all. It goes directly from the token tree, which doesn't represent many important distinctions (like the difference between `hello` and `5KB`) directly into a high-level representation that doesn't have a direct correspondence to the source code. At a high level, nu commands work like macros, in the sense that the syntactic shape of the invocation of a command depends on the definition of a command. However, commands do not have the ability to perform unrestricted expansions of the token tree. Instead, they describe their arguments in terms of syntactic shapes, and the expander expands the token tree into HIR based upon that definition. For example, the `where` command says that it takes a block as its first required argument, and the description of the block syntactic shape expands the syntax `cpu > 10` into HIR that represents `{ $it.cpu > 10 }`. This commit overhauls that system so that the syntactic shapes are described in terms of a few new traits (`ExpandSyntax` and `ExpandExpression` are the primary ones) that are more composable than the previous system. The first big win of this new system is the addition of the `ColumnPath` shape, which looks like `cpu."max ghz"` or `package.version`. Previously, while a variable path could look like `$it.cpu."max ghz"`, the tail of a variable path could not be easily reused in other contexts. Now, that tail is its own syntactic shape, and it can be used as part of a command's signature. This cleans up commands like `inc`, `add` and `edit` as well as shorthand blocks, which can now look like `| where cpu."max ghz" > 10`
2019-09-18 00:26:27 +02:00
pub(crate) use classified::ClassifiedCommand;
pub(crate) use config::Config;
2019-10-15 12:19:06 +02:00
pub(crate) use count::Count;
pub(crate) use cp::Cpy;
pub(crate) use date::Date;
pub(crate) use debug::Debug;
2019-09-08 01:43:53 +02:00
pub(crate) use echo::Echo;
pub(crate) use enter::Enter;
2019-09-16 09:52:58 +02:00
pub(crate) use env::Env;
pub(crate) use exit::Exit;
2019-09-03 08:04:46 +02:00
pub(crate) use fetch::Fetch;
pub(crate) use first::First;
pub(crate) use from_bson::FromBSON;
pub(crate) use from_csv::FromCSV;
pub(crate) use from_ini::FromINI;
pub(crate) use from_json::FromJSON;
2019-08-31 03:30:41 +02:00
pub(crate) use from_sqlite::FromDB;
2019-08-27 23:45:18 +02:00
pub(crate) use from_sqlite::FromSQLite;
2019-10-13 21:15:30 +02:00
pub(crate) use from_ssv::FromSSV;
pub(crate) use from_toml::FromTOML;
pub(crate) use from_tsv::FromTSV;
2019-09-19 06:25:29 +02:00
pub(crate) use from_url::FromURL;
pub(crate) use from_xml::FromXML;
pub(crate) use from_yaml::FromYAML;
2019-08-31 00:13:09 +02:00
pub(crate) use from_yaml::FromYML;
pub(crate) use get::Get;
2019-10-21 01:42:07 +02:00
pub(crate) use group_by::GroupBy;
pub(crate) use help::Help;
pub(crate) use history::History;
pub(crate) use last::Last;
pub(crate) use lines::Lines;
pub(crate) use ls::LS;
pub(crate) use mkdir::Mkdir;
pub(crate) use mv::Move;
pub(crate) use next::Next;
pub(crate) use nth::Nth;
pub(crate) use open::Open;
pub(crate) use pick::Pick;
2019-09-17 09:07:11 +02:00
pub(crate) use pivot::Pivot;
2019-08-30 20:27:15 +02:00
pub(crate) use post::Post;
2019-10-30 07:54:06 +01:00
pub(crate) use prepend::Prepend;
pub(crate) use prev::Previous;
2019-09-07 17:49:15 +02:00
pub(crate) use pwd::PWD;
pub(crate) use reject::Reject;
pub(crate) use reverse::Reverse;
pub(crate) use rm::Remove;
pub(crate) use save::Save;
pub(crate) use shells::Shells;
pub(crate) use size::Size;
pub(crate) use skip_while::SkipWhile;
pub(crate) use sort_by::SortBy;
2019-11-03 22:36:47 +01:00
2019-11-04 02:55:34 +01:00
cfg_if::cfg_if! {
if #[cfg(data_processing_primitives)] {
pub(crate) use split_by::SplitBy;
pub(crate) use reduce_by::ReduceBy;
2019-11-12 08:07:43 +01:00
pub(crate) use evaluate_by::EvaluateBy;
pub(crate) use t_sort_by::TSortBy;
pub(crate) use map_max_by::MapMaxBy;
pub(crate) use histogram::Histogram;
2019-11-04 02:55:34 +01:00
}
}
2019-11-03 22:36:47 +01:00
pub(crate) use split_column::SplitColumn;
pub(crate) use split_row::SplitRow;
pub(crate) use table::Table;
pub(crate) use tags::Tags;
pub(crate) use to_bson::ToBSON;
pub(crate) use to_csv::ToCSV;
pub(crate) use to_json::ToJSON;
2019-08-31 03:30:41 +02:00
pub(crate) use to_sqlite::ToDB;
2019-08-27 23:45:18 +02:00
pub(crate) use to_sqlite::ToSQLite;
pub(crate) use to_toml::ToTOML;
pub(crate) use to_tsv::ToTSV;
2019-09-19 06:25:29 +02:00
pub(crate) use to_url::ToURL;
pub(crate) use to_yaml::ToYAML;
pub(crate) use trim::Trim;
pub(crate) use version::Version;
pub(crate) use where_::Where;
pub(crate) use which_::Which;