2020-02-09 03:24:33 +01:00
|
|
|
use crate::commands::UnevaluatedCallInfo;
|
|
|
|
use crate::commands::WholeStreamCommand;
|
2020-05-11 03:44:49 +02:00
|
|
|
use crate::data::value::format_leaf;
|
2019-06-07 09:50:26 +02:00
|
|
|
use crate::prelude::*;
|
2019-11-30 01:21:05 +01:00
|
|
|
use nu_errors::ShellError;
|
2020-04-13 09:59:57 +02:00
|
|
|
use nu_protocol::{hir, hir::Expression, hir::Literal, hir::SpannedExpression};
|
2020-05-30 01:36:04 +02:00
|
|
|
use nu_protocol::{Primitive, Scope, Signature, UntaggedValue, Value};
|
2020-05-30 20:31:50 +02:00
|
|
|
use parking_lot::Mutex;
|
2020-02-09 03:24:33 +01:00
|
|
|
use std::sync::atomic::AtomicBool;
|
2019-06-07 09:50:26 +02:00
|
|
|
|
2019-08-02 21:15:07 +02:00
|
|
|
pub struct Autoview;
|
|
|
|
|
2020-05-29 10:22:52 +02:00
|
|
|
#[async_trait]
|
2019-08-15 07:02:02 +02:00
|
|
|
impl WholeStreamCommand for Autoview {
|
2019-08-02 21:15:07 +02:00
|
|
|
fn name(&self) -> &str {
|
|
|
|
"autoview"
|
|
|
|
}
|
|
|
|
|
2019-08-30 00:52:32 +02:00
|
|
|
fn signature(&self) -> Signature {
|
|
|
|
Signature::build("autoview")
|
|
|
|
}
|
|
|
|
|
|
|
|
fn usage(&self) -> &str {
|
|
|
|
"View the contents of the pipeline as a table or list."
|
|
|
|
}
|
|
|
|
|
2020-05-29 10:22:52 +02:00
|
|
|
async fn run(
|
2019-08-02 21:15:07 +02:00
|
|
|
&self,
|
|
|
|
args: CommandArgs,
|
|
|
|
registry: &CommandRegistry,
|
|
|
|
) -> Result<OutputStream, ShellError> {
|
2020-02-09 03:24:33 +01:00
|
|
|
autoview(RunnableContext {
|
|
|
|
input: args.input,
|
Move external closer to internal (#1611)
* Refactor InputStream and affected commands.
First, making `values` private and leaning on the `Stream` implementation makes
consumes of `InputStream` less likely to have to change in the future, if we
change what an `InputStream` is internally.
Second, we're dropping `Option<InputStream>` as the input to pipelines,
internals, and externals. Instead, `InputStream.is_empty` can be used to check
for "emptiness". Empty streams are typically only ever used as the first input
to a pipeline.
* Add run_external internal command.
We want to push external commands closer to internal commands, eventually
eliminating the concept of "external" completely. This means we can consolidate
a couple of things:
- Variable evaluation (for example, `$it`, `$nu`, alias vars)
- Behaviour of whole stream vs per-item external execution
It should also make it easier for us to start introducing argument signatures
for external commands,
* Update run_external.rs
* Update run_external.rs
* Update run_external.rs
* Update run_external.rs
Co-authored-by: Jonathan Turner <jonathandturner@users.noreply.github.com>
2020-04-20 05:30:44 +02:00
|
|
|
registry: registry.clone(),
|
2020-02-09 03:24:33 +01:00
|
|
|
shell_manager: args.shell_manager,
|
|
|
|
host: args.host,
|
|
|
|
ctrl_c: args.ctrl_c,
|
2020-05-30 20:31:50 +02:00
|
|
|
current_errors: args.current_errors,
|
2020-02-09 03:24:33 +01:00
|
|
|
name: args.call_info.name_tag,
|
2020-05-20 19:31:04 +02:00
|
|
|
raw_input: args.raw_input,
|
2020-02-09 03:24:33 +01:00
|
|
|
})
|
2020-05-30 01:36:04 +02:00
|
|
|
.await
|
2019-08-02 21:15:07 +02:00
|
|
|
}
|
2020-05-12 03:00:55 +02:00
|
|
|
|
2020-05-18 14:56:01 +02:00
|
|
|
fn examples(&self) -> Vec<Example> {
|
|
|
|
vec![
|
2020-05-12 03:00:55 +02:00
|
|
|
Example {
|
|
|
|
description: "Automatically view the results",
|
|
|
|
example: "ls | autoview",
|
2020-05-18 14:56:01 +02:00
|
|
|
result: None,
|
2020-05-12 03:00:55 +02:00
|
|
|
},
|
|
|
|
Example {
|
|
|
|
description: "Autoview is also implied. The above can be written as",
|
|
|
|
example: "ls",
|
2020-05-18 14:56:01 +02:00
|
|
|
result: None,
|
2020-05-12 03:00:55 +02:00
|
|
|
},
|
|
|
|
]
|
|
|
|
}
|
2019-08-02 21:15:07 +02:00
|
|
|
}
|
|
|
|
|
2020-02-09 03:24:33 +01:00
|
|
|
pub struct RunnableContextWithoutInput {
|
|
|
|
pub shell_manager: ShellManager,
|
|
|
|
pub host: Arc<parking_lot::Mutex<Box<dyn Host>>>,
|
2020-05-30 20:31:50 +02:00
|
|
|
pub current_errors: Arc<Mutex<Vec<ShellError>>>,
|
2020-02-09 03:24:33 +01:00
|
|
|
pub ctrl_c: Arc<AtomicBool>,
|
Move external closer to internal (#1611)
* Refactor InputStream and affected commands.
First, making `values` private and leaning on the `Stream` implementation makes
consumes of `InputStream` less likely to have to change in the future, if we
change what an `InputStream` is internally.
Second, we're dropping `Option<InputStream>` as the input to pipelines,
internals, and externals. Instead, `InputStream.is_empty` can be used to check
for "emptiness". Empty streams are typically only ever used as the first input
to a pipeline.
* Add run_external internal command.
We want to push external commands closer to internal commands, eventually
eliminating the concept of "external" completely. This means we can consolidate
a couple of things:
- Variable evaluation (for example, `$it`, `$nu`, alias vars)
- Behaviour of whole stream vs per-item external execution
It should also make it easier for us to start introducing argument signatures
for external commands,
* Update run_external.rs
* Update run_external.rs
* Update run_external.rs
* Update run_external.rs
Co-authored-by: Jonathan Turner <jonathandturner@users.noreply.github.com>
2020-04-20 05:30:44 +02:00
|
|
|
pub registry: CommandRegistry,
|
2020-02-09 03:24:33 +01:00
|
|
|
pub name: Tag,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl RunnableContextWithoutInput {
|
|
|
|
pub fn convert(context: RunnableContext) -> (InputStream, RunnableContextWithoutInput) {
|
|
|
|
let new_context = RunnableContextWithoutInput {
|
|
|
|
shell_manager: context.shell_manager,
|
|
|
|
host: context.host,
|
|
|
|
ctrl_c: context.ctrl_c,
|
2020-05-30 20:31:50 +02:00
|
|
|
current_errors: context.current_errors,
|
Move external closer to internal (#1611)
* Refactor InputStream and affected commands.
First, making `values` private and leaning on the `Stream` implementation makes
consumes of `InputStream` less likely to have to change in the future, if we
change what an `InputStream` is internally.
Second, we're dropping `Option<InputStream>` as the input to pipelines,
internals, and externals. Instead, `InputStream.is_empty` can be used to check
for "emptiness". Empty streams are typically only ever used as the first input
to a pipeline.
* Add run_external internal command.
We want to push external commands closer to internal commands, eventually
eliminating the concept of "external" completely. This means we can consolidate
a couple of things:
- Variable evaluation (for example, `$it`, `$nu`, alias vars)
- Behaviour of whole stream vs per-item external execution
It should also make it easier for us to start introducing argument signatures
for external commands,
* Update run_external.rs
* Update run_external.rs
* Update run_external.rs
* Update run_external.rs
Co-authored-by: Jonathan Turner <jonathandturner@users.noreply.github.com>
2020-04-20 05:30:44 +02:00
|
|
|
registry: context.registry,
|
2020-02-09 03:24:33 +01:00
|
|
|
name: context.name,
|
|
|
|
};
|
|
|
|
(context.input, new_context)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-30 01:36:04 +02:00
|
|
|
pub async fn autoview(context: RunnableContext) -> Result<OutputStream, ShellError> {
|
2019-10-13 06:12:43 +02:00
|
|
|
let binary = context.get_command("binaryview");
|
|
|
|
let text = context.get_command("textview");
|
|
|
|
let table = context.get_command("table");
|
2020-05-26 00:40:25 +02:00
|
|
|
|
|
|
|
#[derive(PartialEq)]
|
|
|
|
enum AutoPivotMode {
|
|
|
|
Auto,
|
|
|
|
Always,
|
|
|
|
Never,
|
|
|
|
}
|
|
|
|
|
|
|
|
let pivot_mode = crate::data::config::config(Tag::unknown());
|
|
|
|
let pivot_mode = if let Some(v) = pivot_mode?.get("pivot_mode") {
|
|
|
|
match v.as_string() {
|
|
|
|
Ok(m) if m.to_lowercase() == "auto" => AutoPivotMode::Auto,
|
|
|
|
Ok(m) if m.to_lowercase() == "always" => AutoPivotMode::Always,
|
|
|
|
Ok(m) if m.to_lowercase() == "never" => AutoPivotMode::Never,
|
|
|
|
_ => AutoPivotMode::Always,
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
AutoPivotMode::Always
|
2020-05-21 18:30:58 +02:00
|
|
|
};
|
2019-10-13 06:12:43 +02:00
|
|
|
|
2020-05-30 01:36:04 +02:00
|
|
|
let (mut input_stream, context) = RunnableContextWithoutInput::convert(context);
|
2019-11-04 16:47:03 +01:00
|
|
|
|
2020-05-30 01:36:04 +02:00
|
|
|
if let Some(x) = input_stream.next().await {
|
2020-01-25 04:13:12 +01:00
|
|
|
match input_stream.next().await {
|
2020-05-30 01:36:04 +02:00
|
|
|
Some(y) => {
|
|
|
|
let ctrl_c = context.ctrl_c.clone();
|
2020-06-13 21:13:36 +02:00
|
|
|
let xy = vec![x, y];
|
|
|
|
let xy_stream = futures::stream::iter(xy)
|
|
|
|
.chain(input_stream)
|
|
|
|
.interruptible(ctrl_c);
|
2020-05-30 01:36:04 +02:00
|
|
|
|
2020-06-13 21:13:36 +02:00
|
|
|
let stream = InputStream::from_stream(xy_stream);
|
2020-03-06 17:06:39 +01:00
|
|
|
|
2020-05-30 01:36:04 +02:00
|
|
|
if let Some(table) = table {
|
|
|
|
let command_args = create_default_command_args(&context).with_input(stream);
|
|
|
|
let result = table.run(command_args, &context.registry).await;
|
|
|
|
result.collect::<Vec<_>>().await;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_ => {
|
|
|
|
match x {
|
|
|
|
Value {
|
|
|
|
value: UntaggedValue::Primitive(Primitive::String(ref s)),
|
|
|
|
tag: Tag { anchor, span },
|
|
|
|
} if anchor.is_some() => {
|
|
|
|
if let Some(text) = text {
|
|
|
|
let mut stream = VecDeque::new();
|
|
|
|
stream.push_back(
|
|
|
|
UntaggedValue::string(s).into_value(Tag { anchor, span }),
|
|
|
|
);
|
|
|
|
let command_args =
|
|
|
|
create_default_command_args(&context).with_input(stream);
|
|
|
|
let result = text.run(command_args, &context.registry).await;
|
2020-01-25 04:13:12 +01:00
|
|
|
result.collect::<Vec<_>>().await;
|
2020-05-30 01:36:04 +02:00
|
|
|
} else {
|
|
|
|
out!("{}", s);
|
Overhaul the coloring system
This commit replaces the previous naive coloring system with a coloring
system that is more aligned with the parser.
The main benefit of this change is that it allows us to use parsing
rules to decide how to color tokens.
For example, consider the following syntax:
```
$ ps | where cpu > 10
```
Ideally, we could color `cpu` like a column name and not a string,
because `cpu > 10` is a shorthand block syntax that expands to
`{ $it.cpu > 10 }`.
The way that we know that it's a shorthand block is that the `where`
command declares that its first parameter is a `SyntaxShape::Block`,
which allows the shorthand block form.
In order to accomplish this, we need to color the tokens in a way that
corresponds to their expanded semantics, which means that high-fidelity
coloring requires expansion.
This commit adds a `ColorSyntax` trait that corresponds to the
`ExpandExpression` trait. The semantics are fairly similar, with a few
differences.
First `ExpandExpression` consumes N tokens and returns a single
`hir::Expression`. `ColorSyntax` consumes N tokens and writes M
`FlatShape` tokens to the output.
Concretely, for syntax like `[1 2 3]`
- `ExpandExpression` takes a single token node and produces a single
`hir::Expression`
- `ColorSyntax` takes the same token node and emits 7 `FlatShape`s
(open delimiter, int, whitespace, int, whitespace, int, close
delimiter)
Second, `ColorSyntax` is more willing to plow through failures than
`ExpandExpression`.
In particular, consider syntax like
```
$ ps | where cpu >
```
In this case
- `ExpandExpression` will see that the `where` command is expecting a
block, see that it's not a literal block and try to parse it as a
shorthand block. It will successfully find a member followed by an
infix operator, but not a following expression. That means that the
entire pipeline part fails to parse and is a syntax error.
- `ColorSyntax` will also try to parse it as a shorthand block and
ultimately fail, but it will fall back to "backoff coloring mode",
which parsing any unidentified tokens in an unfallible, simple way. In
this case, `cpu` will color as a string and `>` will color as an
operator.
Finally, it's very important that coloring a pipeline infallibly colors
the entire string, doesn't fail, and doesn't get stuck in an infinite
loop.
In order to accomplish this, this PR separates `ColorSyntax`, which is
infallible from `FallibleColorSyntax`, which might fail. This allows the
type system to let us know if our coloring rules bottom out at at an
infallible rule.
It's not perfect: it's still possible for the coloring process to get
stuck or consume tokens non-atomically. I intend to reduce the
opportunity for those problems in a future commit. In the meantime, the
current system catches a number of mistakes (like trying to use a
fallible coloring rule in a loop without thinking about the possibility
that it will never terminate).
2019-10-06 22:22:50 +02:00
|
|
|
}
|
|
|
|
}
|
2020-05-30 01:36:04 +02:00
|
|
|
Value {
|
|
|
|
value: UntaggedValue::Primitive(Primitive::String(s)),
|
|
|
|
..
|
|
|
|
} => {
|
|
|
|
out!("{}", s);
|
|
|
|
}
|
|
|
|
Value {
|
|
|
|
value: UntaggedValue::Primitive(Primitive::Line(ref s)),
|
|
|
|
tag: Tag { anchor, span },
|
|
|
|
} if anchor.is_some() => {
|
|
|
|
if let Some(text) = text {
|
|
|
|
let mut stream = VecDeque::new();
|
|
|
|
stream.push_back(
|
|
|
|
UntaggedValue::string(s).into_value(Tag { anchor, span }),
|
|
|
|
);
|
|
|
|
let command_args =
|
|
|
|
create_default_command_args(&context).with_input(stream);
|
|
|
|
let result = text.run(command_args, &context.registry).await;
|
|
|
|
result.collect::<Vec<_>>().await;
|
|
|
|
} else {
|
|
|
|
out!("{}\n", s);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Value {
|
|
|
|
value: UntaggedValue::Primitive(Primitive::Line(s)),
|
|
|
|
..
|
|
|
|
} => {
|
|
|
|
out!("{}\n", s);
|
|
|
|
}
|
|
|
|
Value {
|
|
|
|
value: UntaggedValue::Primitive(Primitive::Path(s)),
|
|
|
|
..
|
|
|
|
} => {
|
|
|
|
out!("{}", s.display());
|
|
|
|
}
|
|
|
|
Value {
|
|
|
|
value: UntaggedValue::Primitive(Primitive::Int(n)),
|
|
|
|
..
|
|
|
|
} => {
|
|
|
|
out!("{}", n);
|
|
|
|
}
|
|
|
|
Value {
|
|
|
|
value: UntaggedValue::Primitive(Primitive::Decimal(n)),
|
|
|
|
..
|
|
|
|
} => {
|
|
|
|
// TODO: normalize decimal to remove trailing zeros.
|
|
|
|
// normalization will be available in next release of bigdecimal crate
|
|
|
|
let mut output = n.to_string();
|
|
|
|
if output.contains('.') {
|
|
|
|
output = output.trim_end_matches('0').to_owned();
|
|
|
|
}
|
|
|
|
if output.ends_with('.') {
|
|
|
|
output.push('0');
|
|
|
|
}
|
|
|
|
out!("{}", output);
|
|
|
|
}
|
|
|
|
Value {
|
|
|
|
value: UntaggedValue::Primitive(Primitive::Boolean(b)),
|
|
|
|
..
|
|
|
|
} => {
|
|
|
|
out!("{}", b);
|
|
|
|
}
|
|
|
|
Value {
|
|
|
|
value: UntaggedValue::Primitive(Primitive::Duration(_)),
|
|
|
|
..
|
|
|
|
} => {
|
|
|
|
let output = format_leaf(&x).plain_string(100_000);
|
|
|
|
out!("{}", output);
|
|
|
|
}
|
|
|
|
Value {
|
|
|
|
value: UntaggedValue::Primitive(Primitive::Date(d)),
|
|
|
|
..
|
|
|
|
} => {
|
|
|
|
out!("{}", d);
|
|
|
|
}
|
|
|
|
Value {
|
|
|
|
value: UntaggedValue::Primitive(Primitive::Range(_)),
|
|
|
|
..
|
|
|
|
} => {
|
|
|
|
let output = format_leaf(&x).plain_string(100_000);
|
|
|
|
out!("{}", output);
|
|
|
|
}
|
2019-10-13 06:12:43 +02:00
|
|
|
|
2020-05-30 01:36:04 +02:00
|
|
|
Value {
|
|
|
|
value: UntaggedValue::Primitive(Primitive::Binary(ref b)),
|
|
|
|
..
|
|
|
|
} => {
|
|
|
|
if let Some(binary) = binary {
|
|
|
|
let mut stream = VecDeque::new();
|
|
|
|
stream.push_back(x);
|
|
|
|
let command_args =
|
|
|
|
create_default_command_args(&context).with_input(stream);
|
|
|
|
let result = binary.run(command_args, &context.registry).await;
|
|
|
|
result.collect::<Vec<_>>().await;
|
|
|
|
} else {
|
|
|
|
use pretty_hex::*;
|
|
|
|
out!("{:?}", b.hex_dump());
|
|
|
|
}
|
|
|
|
}
|
2019-10-13 06:12:43 +02:00
|
|
|
|
2020-05-30 01:36:04 +02:00
|
|
|
Value {
|
|
|
|
value: UntaggedValue::Error(e),
|
|
|
|
..
|
|
|
|
} => {
|
|
|
|
return Err(e);
|
|
|
|
}
|
2020-03-22 21:55:30 +01:00
|
|
|
|
2020-05-30 01:36:04 +02:00
|
|
|
Value {
|
|
|
|
value: UntaggedValue::Row(row),
|
|
|
|
..
|
|
|
|
} if pivot_mode == AutoPivotMode::Always
|
|
|
|
|| (pivot_mode == AutoPivotMode::Auto
|
|
|
|
&& (row
|
|
|
|
.entries
|
|
|
|
.iter()
|
|
|
|
.map(|(_, v)| v.convert_to_string())
|
|
|
|
.collect::<Vec<_>>()
|
|
|
|
.iter()
|
|
|
|
.fold(0usize, |acc, len| acc + len.len())
|
|
|
|
+ row.entries.iter().count() * 2)
|
|
|
|
> textwrap::termwidth()) =>
|
|
|
|
{
|
2020-06-20 21:25:07 +02:00
|
|
|
let mut entries = vec![];
|
2020-05-30 01:36:04 +02:00
|
|
|
for (key, value) in row.entries.iter() {
|
2020-06-20 21:25:07 +02:00
|
|
|
entries.push(vec![
|
|
|
|
nu_table::StyledString::new(
|
|
|
|
key.to_string(),
|
|
|
|
nu_table::TextStyle {
|
|
|
|
alignment: nu_table::Alignment::Left,
|
|
|
|
color: Some(ansi_term::Color::Green),
|
|
|
|
is_bold: true,
|
|
|
|
},
|
|
|
|
),
|
|
|
|
nu_table::StyledString::new(
|
|
|
|
format_leaf(value).plain_string(100_000),
|
|
|
|
nu_table::TextStyle::basic(),
|
|
|
|
),
|
|
|
|
]);
|
2020-05-30 01:36:04 +02:00
|
|
|
}
|
2020-03-22 21:55:30 +01:00
|
|
|
|
2020-06-20 21:25:07 +02:00
|
|
|
let table =
|
|
|
|
nu_table::Table::new(vec![], entries, nu_table::Theme::compact());
|
2020-03-22 21:55:30 +01:00
|
|
|
|
2020-06-20 21:25:07 +02:00
|
|
|
nu_table::draw_table(&table, textwrap::termwidth());
|
2020-05-30 01:36:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Value {
|
|
|
|
value: ref item, ..
|
|
|
|
} => {
|
|
|
|
if let Some(table) = table {
|
|
|
|
let mut stream = VecDeque::new();
|
|
|
|
stream.push_back(x);
|
|
|
|
let command_args =
|
|
|
|
create_default_command_args(&context).with_input(stream);
|
|
|
|
let result = table.run(command_args, &context.registry).await;
|
|
|
|
result.collect::<Vec<_>>().await;
|
|
|
|
} else {
|
|
|
|
out!("{:?}", item);
|
2019-09-08 03:35:02 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-10-13 06:12:43 +02:00
|
|
|
}
|
2019-06-07 09:50:26 +02:00
|
|
|
}
|
2020-05-30 01:36:04 +02:00
|
|
|
}
|
2019-09-28 02:05:18 +02:00
|
|
|
|
2020-05-30 01:36:04 +02:00
|
|
|
Ok(OutputStream::empty())
|
2019-06-07 09:50:26 +02:00
|
|
|
}
|
2020-02-09 03:24:33 +01:00
|
|
|
|
|
|
|
fn create_default_command_args(context: &RunnableContextWithoutInput) -> RawCommandArgs {
|
|
|
|
let span = context.name.span;
|
|
|
|
RawCommandArgs {
|
|
|
|
host: context.host.clone(),
|
|
|
|
ctrl_c: context.ctrl_c.clone(),
|
2020-05-30 20:31:50 +02:00
|
|
|
current_errors: context.current_errors.clone(),
|
2020-02-09 03:24:33 +01:00
|
|
|
shell_manager: context.shell_manager.clone(),
|
|
|
|
call_info: UnevaluatedCallInfo {
|
|
|
|
args: hir::Call {
|
|
|
|
head: Box::new(SpannedExpression::new(
|
2020-04-06 09:16:14 +02:00
|
|
|
Expression::Literal(Literal::String(String::new())),
|
2020-02-09 03:24:33 +01:00
|
|
|
span,
|
|
|
|
)),
|
|
|
|
positional: None,
|
|
|
|
named: None,
|
|
|
|
span,
|
Move external closer to internal (#1611)
* Refactor InputStream and affected commands.
First, making `values` private and leaning on the `Stream` implementation makes
consumes of `InputStream` less likely to have to change in the future, if we
change what an `InputStream` is internally.
Second, we're dropping `Option<InputStream>` as the input to pipelines,
internals, and externals. Instead, `InputStream.is_empty` can be used to check
for "emptiness". Empty streams are typically only ever used as the first input
to a pipeline.
* Add run_external internal command.
We want to push external commands closer to internal commands, eventually
eliminating the concept of "external" completely. This means we can consolidate
a couple of things:
- Variable evaluation (for example, `$it`, `$nu`, alias vars)
- Behaviour of whole stream vs per-item external execution
It should also make it easier for us to start introducing argument signatures
for external commands,
* Update run_external.rs
* Update run_external.rs
* Update run_external.rs
* Update run_external.rs
Co-authored-by: Jonathan Turner <jonathandturner@users.noreply.github.com>
2020-04-20 05:30:44 +02:00
|
|
|
is_last: true,
|
2020-02-09 03:24:33 +01:00
|
|
|
},
|
|
|
|
name_tag: context.name.clone(),
|
2020-05-27 06:50:26 +02:00
|
|
|
scope: Scope::new(),
|
2020-02-09 03:24:33 +01:00
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
2020-05-18 14:56:01 +02:00
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
mod tests {
|
|
|
|
use super::Autoview;
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn examples_work_as_expected() {
|
|
|
|
use crate::examples::test as test_examples;
|
|
|
|
|
|
|
|
test_examples(Autoview {})
|
|
|
|
}
|
|
|
|
}
|