2019-08-30 19:29:04 +02:00
|
|
|
use crate::commands::{UnevaluatedCallInfo, WholeStreamCommand};
|
2019-08-02 21:15:07 +02:00
|
|
|
use crate::prelude::*;
|
Extract core stuff into own crates
This commit extracts five new crates:
- nu-source, which contains the core source-code handling logic in Nu,
including Text, Span, and also the pretty.rs-based debug logic
- nu-parser, which is the parser and expander logic
- nu-protocol, which is the bulk of the types and basic conveniences
used by plugins
- nu-errors, which contains ShellError, ParseError and error handling
conveniences
- nu-textview, which is the textview plugin extracted into a crate
One of the major consequences of this refactor is that it's no longer
possible to `impl X for Spanned<Y>` outside of the `nu-source` crate, so
a lot of types became more concrete (Value became a concrete type
instead of Spanned<Value>, for example).
This also turned a number of inherent methods in the main nu crate into
plain functions (impl Value {} became a bunch of functions in the
`value` namespace in `crate::data::value`).
2019-11-26 03:30:48 +01:00
|
|
|
use nu_errors::ShellError;
|
2020-05-06 05:56:31 +02:00
|
|
|
use nu_protocol::{Primitive, ReturnSuccess, Signature, SyntaxShape, UntaggedValue, Value};
|
2019-11-21 15:33:14 +01:00
|
|
|
use nu_source::Tagged;
|
2019-08-09 07:36:43 +02:00
|
|
|
use std::path::{Path, PathBuf};
|
2019-06-07 19:13:38 +02:00
|
|
|
|
2019-08-02 21:15:07 +02:00
|
|
|
pub struct Save;
|
|
|
|
|
2020-03-07 19:33:29 +01:00
|
|
|
macro_rules! process_unknown {
|
|
|
|
($scope:tt, $input:ident, $name_tag:ident) => {{
|
|
|
|
if $input.len() > 0 {
|
|
|
|
match $input[0] {
|
|
|
|
Value {
|
|
|
|
value: UntaggedValue::Primitive(Primitive::Binary(_)),
|
|
|
|
..
|
|
|
|
} => process_binary!($scope, $input, $name_tag),
|
|
|
|
_ => process_string!($scope, $input, $name_tag),
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
process_string!($scope, $input, $name_tag)
|
|
|
|
}
|
|
|
|
}};
|
|
|
|
}
|
|
|
|
|
2019-09-04 04:21:37 +02:00
|
|
|
macro_rules! process_string {
|
2019-09-28 02:05:18 +02:00
|
|
|
($scope:tt, $input:ident, $name_tag:ident) => {{
|
2019-09-04 04:21:37 +02:00
|
|
|
let mut result_string = String::new();
|
|
|
|
for res in $input {
|
|
|
|
match res {
|
2019-11-21 15:33:14 +01:00
|
|
|
Value {
|
|
|
|
value: UntaggedValue::Primitive(Primitive::String(s)),
|
2019-09-04 04:21:37 +02:00
|
|
|
..
|
|
|
|
} => {
|
|
|
|
result_string.push_str(&s);
|
|
|
|
}
|
|
|
|
_ => {
|
2019-09-28 02:05:18 +02:00
|
|
|
break $scope Err(ShellError::labeled_error(
|
2019-11-17 02:13:52 +01:00
|
|
|
"Save requires string data",
|
|
|
|
"consider converting data to string (see `help commands`)",
|
2019-09-14 18:30:24 +02:00
|
|
|
$name_tag,
|
2019-09-28 02:05:18 +02:00
|
|
|
));
|
2019-09-04 04:21:37 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Ok(result_string.into_bytes())
|
|
|
|
}};
|
|
|
|
}
|
|
|
|
|
2020-03-07 19:33:29 +01:00
|
|
|
macro_rules! process_binary {
|
|
|
|
($scope:tt, $input:ident, $name_tag:ident) => {{
|
|
|
|
let mut result_binary: Vec<u8> = Vec::new();
|
|
|
|
for res in $input {
|
|
|
|
match res {
|
|
|
|
Value {
|
|
|
|
value: UntaggedValue::Primitive(Primitive::Binary(b)),
|
|
|
|
..
|
|
|
|
} => {
|
|
|
|
for u in b.into_iter() {
|
|
|
|
result_binary.push(u);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_ => {
|
|
|
|
break $scope Err(ShellError::labeled_error(
|
|
|
|
"Save could not successfully save",
|
|
|
|
"unexpected data during binary save",
|
|
|
|
$name_tag,
|
|
|
|
));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Ok(result_binary)
|
|
|
|
}};
|
|
|
|
}
|
|
|
|
|
2019-09-04 04:21:37 +02:00
|
|
|
macro_rules! process_string_return_success {
|
2019-09-28 02:05:18 +02:00
|
|
|
($scope:tt, $result_vec:ident, $name_tag:ident) => {{
|
2019-09-04 04:21:37 +02:00
|
|
|
let mut result_string = String::new();
|
|
|
|
for res in $result_vec {
|
|
|
|
match res {
|
2019-11-21 15:33:14 +01:00
|
|
|
Ok(ReturnSuccess::Value(Value {
|
|
|
|
value: UntaggedValue::Primitive(Primitive::String(s)),
|
2019-09-04 04:21:37 +02:00
|
|
|
..
|
|
|
|
})) => {
|
|
|
|
result_string.push_str(&s);
|
|
|
|
}
|
|
|
|
_ => {
|
2019-09-28 02:05:18 +02:00
|
|
|
break $scope Err(ShellError::labeled_error(
|
2019-09-04 04:21:37 +02:00
|
|
|
"Save could not successfully save",
|
|
|
|
"unexpected data during text save",
|
2019-09-14 18:30:24 +02:00
|
|
|
$name_tag,
|
2019-09-28 02:05:18 +02:00
|
|
|
));
|
2019-09-04 04:21:37 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Ok(result_string.into_bytes())
|
|
|
|
}};
|
|
|
|
}
|
|
|
|
|
|
|
|
macro_rules! process_binary_return_success {
|
2019-09-28 02:05:18 +02:00
|
|
|
($scope:tt, $result_vec:ident, $name_tag:ident) => {{
|
2019-09-04 04:21:37 +02:00
|
|
|
let mut result_binary: Vec<u8> = Vec::new();
|
|
|
|
for res in $result_vec {
|
|
|
|
match res {
|
2019-11-21 15:33:14 +01:00
|
|
|
Ok(ReturnSuccess::Value(Value {
|
|
|
|
value: UntaggedValue::Primitive(Primitive::Binary(b)),
|
2019-09-04 04:21:37 +02:00
|
|
|
..
|
|
|
|
})) => {
|
|
|
|
for u in b.into_iter() {
|
|
|
|
result_binary.push(u);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_ => {
|
2019-09-28 02:05:18 +02:00
|
|
|
break $scope Err(ShellError::labeled_error(
|
2019-09-04 04:21:37 +02:00
|
|
|
"Save could not successfully save",
|
|
|
|
"unexpected data during binary save",
|
2019-09-14 18:30:24 +02:00
|
|
|
$name_tag,
|
2019-09-28 02:05:18 +02:00
|
|
|
));
|
2019-09-04 04:21:37 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Ok(result_binary)
|
|
|
|
}};
|
|
|
|
}
|
|
|
|
|
2019-08-02 21:15:07 +02:00
|
|
|
#[derive(Deserialize)]
|
2019-08-03 04:17:28 +02:00
|
|
|
pub struct SaveArgs {
|
2019-08-09 07:36:43 +02:00
|
|
|
path: Option<Tagged<PathBuf>>,
|
2019-08-02 21:15:07 +02:00
|
|
|
raw: bool,
|
|
|
|
}
|
|
|
|
|
2019-08-15 07:02:02 +02:00
|
|
|
impl WholeStreamCommand for Save {
|
2019-08-02 21:15:07 +02:00
|
|
|
fn name(&self) -> &str {
|
|
|
|
"save"
|
2019-06-07 19:13:38 +02:00
|
|
|
}
|
|
|
|
|
2019-08-02 21:15:07 +02:00
|
|
|
fn signature(&self) -> Signature {
|
|
|
|
Signature::build("save")
|
2019-10-28 06:15:35 +01:00
|
|
|
.optional("path", SyntaxShape::Path, "the path to save contents to")
|
|
|
|
.switch(
|
|
|
|
"raw",
|
|
|
|
"treat values as-is rather than auto-converting based on file extension",
|
2020-02-12 03:24:31 +01:00
|
|
|
Some('r'),
|
2019-10-28 06:15:35 +01:00
|
|
|
)
|
2019-08-02 21:15:07 +02:00
|
|
|
}
|
2019-06-22 05:43:37 +02:00
|
|
|
|
2019-08-30 00:52:32 +02:00
|
|
|
fn usage(&self) -> &str {
|
|
|
|
"Save the contents of the pipeline to a file."
|
|
|
|
}
|
|
|
|
|
2019-08-02 21:15:07 +02:00
|
|
|
fn run(
|
|
|
|
&self,
|
|
|
|
args: CommandArgs,
|
|
|
|
registry: &CommandRegistry,
|
|
|
|
) -> Result<OutputStream, ShellError> {
|
2019-08-31 02:59:21 +02:00
|
|
|
Ok(args.process_raw(registry, save)?.run())
|
2019-06-07 19:13:38 +02:00
|
|
|
}
|
2019-08-02 21:15:07 +02:00
|
|
|
}
|
2019-06-07 19:13:38 +02:00
|
|
|
|
2019-08-21 14:08:23 +02:00
|
|
|
fn save(
|
2019-08-02 21:15:07 +02:00
|
|
|
SaveArgs {
|
|
|
|
path,
|
|
|
|
raw: save_raw,
|
|
|
|
}: SaveArgs,
|
2019-08-21 14:08:23 +02:00
|
|
|
RunnableContext {
|
|
|
|
input,
|
|
|
|
name,
|
|
|
|
shell_manager,
|
2019-08-31 02:59:21 +02:00
|
|
|
host,
|
2019-10-13 06:12:43 +02:00
|
|
|
ctrl_c,
|
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,
|
2019-08-21 14:08:23 +02:00
|
|
|
..
|
|
|
|
}: RunnableContext,
|
2019-08-31 02:59:21 +02:00
|
|
|
raw_args: RawCommandArgs,
|
2019-08-02 21:15:07 +02:00
|
|
|
) -> Result<OutputStream, ShellError> {
|
Restructure and streamline token expansion (#1123)
Restructure and streamline token expansion
The purpose of this commit is to streamline the token expansion code, by
removing aspects of the code that are no longer relevant, removing
pointless duplication, and eliminating the need to pass the same
arguments to `expand_syntax`.
The first big-picture change in this commit is that instead of a handful
of `expand_` functions, which take a TokensIterator and ExpandContext, a
smaller number of methods on the `TokensIterator` do the same job.
The second big-picture change in this commit is fully eliminating the
coloring traits, making coloring a responsibility of the base expansion
implementations. This also means that the coloring tracer is merged into
the expansion tracer, so you can follow a single expansion and see how
the expansion process produced colored tokens.
One side effect of this change is that the expander itself is marginally
more error-correcting. The error correction works by switching from
structured expansion to `BackoffColoringMode` when an unexpected token
is found, which guarantees that all spans of the source are colored, but
may not be the most optimal error recovery strategy.
That said, because `BackoffColoringMode` only extends as far as a
closing delimiter (`)`, `]`, `}`) or pipe (`|`), it does result in
fairly granular correction strategy.
The current code still produces an `Err` (plus a complete list of
colored shapes) from the parsing process if any errors are encountered,
but this could easily be addressed now that the underlying expansion is
error-correcting.
This commit also colors any spans that are syntax errors in red, and
causes the parser to include some additional information about what
tokens were expected at any given point where an error was encountered,
so that completions and hinting could be more robust in the future.
Co-authored-by: Jonathan Turner <jonathandturner@users.noreply.github.com>
Co-authored-by: Andrés N. Robalino <andres@androbtech.com>
2020-01-21 23:45:03 +01:00
|
|
|
let mut full_path = PathBuf::from(shell_manager.path());
|
2019-10-13 06:12:43 +02:00
|
|
|
let name_tag = name.clone();
|
2020-05-06 05:56:31 +02:00
|
|
|
let scope = raw_args.call_info.scope.clone();
|
2019-08-02 21:15:07 +02:00
|
|
|
|
2019-09-28 02:05:18 +02:00
|
|
|
let stream = async_stream! {
|
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
|
|
|
let input: Vec<Value> = input.collect().await;
|
2019-08-31 02:59:21 +02:00
|
|
|
if path.is_none() {
|
2019-09-29 07:13:56 +02:00
|
|
|
// If there is no filename, check the metadata for the anchor filename
|
2019-08-09 07:36:43 +02:00
|
|
|
if input.len() > 0 {
|
2019-11-21 15:33:14 +01:00
|
|
|
let anchor = input[0].tag.anchor();
|
2019-10-13 06:12:43 +02:00
|
|
|
match anchor {
|
2019-08-09 07:36:43 +02:00
|
|
|
Some(path) => match path {
|
2019-09-29 07:18:59 +02:00
|
|
|
AnchorLocation::File(file) => {
|
2019-10-13 06:12:43 +02:00
|
|
|
full_path.push(Path::new(&file));
|
2019-08-09 07:36:43 +02:00
|
|
|
}
|
|
|
|
_ => {
|
2019-08-09 22:49:43 +02:00
|
|
|
yield Err(ShellError::labeled_error(
|
2019-12-03 07:44:59 +01:00
|
|
|
"Save requires a filepath",
|
2019-08-09 22:49:43 +02:00
|
|
|
"needs path",
|
2019-10-13 06:12:43 +02:00
|
|
|
name_tag.clone(),
|
2019-08-09 22:49:43 +02:00
|
|
|
));
|
2019-08-09 07:36:43 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
None => {
|
2019-08-09 22:49:43 +02:00
|
|
|
yield Err(ShellError::labeled_error(
|
2019-12-03 07:44:59 +01:00
|
|
|
"Save requires a filepath",
|
2019-08-09 22:49:43 +02:00
|
|
|
"needs path",
|
2019-10-13 06:12:43 +02:00
|
|
|
name_tag.clone(),
|
2019-08-09 22:49:43 +02:00
|
|
|
));
|
2019-08-09 07:36:43 +02:00
|
|
|
}
|
2019-08-02 21:15:07 +02:00
|
|
|
}
|
2019-08-09 07:36:43 +02:00
|
|
|
} else {
|
2019-08-09 22:49:43 +02:00
|
|
|
yield Err(ShellError::labeled_error(
|
2019-12-03 07:44:59 +01:00
|
|
|
"Save requires a filepath",
|
2019-08-09 22:49:43 +02:00
|
|
|
"needs path",
|
2019-10-13 06:12:43 +02:00
|
|
|
name_tag.clone(),
|
2019-08-09 22:49:43 +02:00
|
|
|
));
|
2019-07-21 09:08:05 +02:00
|
|
|
}
|
2019-08-31 02:59:21 +02:00
|
|
|
} else {
|
|
|
|
if let Some(file) = path {
|
|
|
|
full_path.push(file.item());
|
2019-08-21 14:08:23 +02:00
|
|
|
}
|
|
|
|
}
|
2019-08-09 07:36:43 +02:00
|
|
|
|
2019-09-28 02:05:18 +02:00
|
|
|
// TODO use label_break_value once it is stable:
|
|
|
|
// https://github.com/rust-lang/rust/issues/48594
|
|
|
|
let content : Result<Vec<u8>, ShellError> = 'scope: loop {
|
|
|
|
break if !save_raw {
|
|
|
|
if let Some(extension) = full_path.extension() {
|
2020-05-04 10:44:33 +02:00
|
|
|
let command_name = format!("to {}", extension.to_string_lossy());
|
Restructure and streamline token expansion (#1123)
Restructure and streamline token expansion
The purpose of this commit is to streamline the token expansion code, by
removing aspects of the code that are no longer relevant, removing
pointless duplication, and eliminating the need to pass the same
arguments to `expand_syntax`.
The first big-picture change in this commit is that instead of a handful
of `expand_` functions, which take a TokensIterator and ExpandContext, a
smaller number of methods on the `TokensIterator` do the same job.
The second big-picture change in this commit is fully eliminating the
coloring traits, making coloring a responsibility of the base expansion
implementations. This also means that the coloring tracer is merged into
the expansion tracer, so you can follow a single expansion and see how
the expansion process produced colored tokens.
One side effect of this change is that the expander itself is marginally
more error-correcting. The error correction works by switching from
structured expansion to `BackoffColoringMode` when an unexpected token
is found, which guarantees that all spans of the source are colored, but
may not be the most optimal error recovery strategy.
That said, because `BackoffColoringMode` only extends as far as a
closing delimiter (`)`, `]`, `}`) or pipe (`|`), it does result in
fairly granular correction strategy.
The current code still produces an `Err` (plus a complete list of
colored shapes) from the parsing process if any errors are encountered,
but this could easily be addressed now that the underlying expansion is
error-correcting.
This commit also colors any spans that are syntax errors in red, and
causes the parser to include some additional information about what
tokens were expected at any given point where an error was encountered,
so that completions and hinting could be more robust in the future.
Co-authored-by: Jonathan Turner <jonathandturner@users.noreply.github.com>
Co-authored-by: Andrés N. Robalino <andres@androbtech.com>
2020-01-21 23:45:03 +01:00
|
|
|
if let Some(converter) = registry.get_command(&command_name) {
|
2019-09-28 02:05:18 +02:00
|
|
|
let new_args = RawCommandArgs {
|
|
|
|
host,
|
2019-10-13 06:12:43 +02:00
|
|
|
ctrl_c,
|
2019-09-28 02:05:18 +02:00
|
|
|
shell_manager,
|
|
|
|
call_info: UnevaluatedCallInfo {
|
2020-04-13 09:59:57 +02:00
|
|
|
args: nu_protocol::hir::Call {
|
2019-09-28 02:05:18 +02:00
|
|
|
head: raw_args.call_info.args.head,
|
|
|
|
positional: None,
|
2019-11-21 15:33:14 +01:00
|
|
|
named: None,
|
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
|
|
|
span: Span::unknown(),
|
|
|
|
is_last: false,
|
2019-09-28 02:05:18 +02:00
|
|
|
},
|
|
|
|
name_tag: raw_args.call_info.name_tag,
|
2020-05-06 05:56:31 +02:00
|
|
|
scope,
|
2019-09-28 02:05:18 +02:00
|
|
|
}
|
|
|
|
};
|
2019-11-04 02:04:01 +01:00
|
|
|
let mut result = converter.run(new_args.with_input(input), ®istry);
|
2019-09-28 02:05:18 +02:00
|
|
|
let result_vec: Vec<Result<ReturnSuccess, ShellError>> = result.drain_vec().await;
|
|
|
|
if converter.is_binary() {
|
|
|
|
process_binary_return_success!('scope, result_vec, name_tag)
|
|
|
|
} else {
|
|
|
|
process_string_return_success!('scope, result_vec, name_tag)
|
2019-08-31 02:59:21 +02:00
|
|
|
}
|
2019-09-04 03:50:23 +02:00
|
|
|
} else {
|
2020-03-07 19:33:29 +01:00
|
|
|
process_unknown!('scope, input, name_tag)
|
2019-08-31 02:59:21 +02:00
|
|
|
}
|
|
|
|
} else {
|
2020-03-07 19:33:29 +01:00
|
|
|
process_unknown!('scope, input, name_tag)
|
2019-08-31 02:59:21 +02:00
|
|
|
}
|
2019-08-21 14:08:23 +02:00
|
|
|
} else {
|
2019-09-28 02:05:18 +02:00
|
|
|
Ok(string_from(&input).into_bytes())
|
|
|
|
};
|
2019-08-31 02:59:21 +02:00
|
|
|
};
|
2019-08-09 07:36:43 +02:00
|
|
|
|
2019-08-31 02:59:21 +02:00
|
|
|
match content {
|
|
|
|
Ok(save_data) => match std::fs::write(full_path, save_data) {
|
|
|
|
Ok(o) => o,
|
2019-11-17 01:04:33 +01:00
|
|
|
Err(e) => yield Err(ShellError::labeled_error(e.to_string(), "IO error while saving", name)),
|
2019-08-31 02:59:21 +02:00
|
|
|
},
|
2019-11-17 01:04:33 +01:00
|
|
|
Err(e) => yield Err(e),
|
2019-08-31 02:59:21 +02:00
|
|
|
}
|
2019-08-21 14:08:23 +02:00
|
|
|
|
2019-08-31 02:59:21 +02:00
|
|
|
};
|
2019-08-09 07:36:43 +02:00
|
|
|
|
2019-08-31 02:59:21 +02:00
|
|
|
Ok(OutputStream::new(stream))
|
2019-06-07 19:13:38 +02:00
|
|
|
}
|
2019-08-21 14:08:23 +02:00
|
|
|
|
2019-12-06 16:28:26 +01:00
|
|
|
fn string_from(input: &[Value]) -> String {
|
2019-08-21 14:08:23 +02:00
|
|
|
let mut save_data = String::new();
|
|
|
|
|
2019-12-06 16:28:26 +01:00
|
|
|
if !input.is_empty() {
|
2019-08-21 14:08:23 +02:00
|
|
|
let mut first = true;
|
|
|
|
for i in input.iter() {
|
|
|
|
if !first {
|
|
|
|
save_data.push_str("\n");
|
|
|
|
} else {
|
|
|
|
first = false;
|
|
|
|
}
|
|
|
|
if let Ok(data) = &i.as_string() {
|
|
|
|
save_data.push_str(data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-04 03:50:23 +02:00
|
|
|
save_data
|
2019-08-21 14:08:23 +02:00
|
|
|
}
|