Compare commits
No commits in common. "46e2057b1c434202557321f89926f1780fd86785" and "da532b79f315e00158d744cd033ee15f6ab29ce6" have entirely different histories.
46e2057b1c
...
da532b79f3
14
README.md
14
README.md
@ -120,7 +120,7 @@ Lists are sequential collections. They can be built by grouping values with pare
|
||||
```dust
|
||||
list = (true, 42, "Ok");
|
||||
|
||||
assert_equal(list.0, true);
|
||||
assert_eq(list.0, true);
|
||||
```
|
||||
|
||||
### Maps
|
||||
@ -132,7 +132,7 @@ reminder.message = "Buy milk";
|
||||
reminder.tags = ("groceries", "home");
|
||||
|
||||
json = to_json(reminder);
|
||||
append(json, "info.txt");
|
||||
append_to_file(json, "info.txt");
|
||||
```
|
||||
|
||||
### Tables
|
||||
@ -170,7 +170,7 @@ insert(
|
||||
|
||||
assert_eq(length(animals.all), 6);
|
||||
|
||||
sorted = sort(animals, "name");
|
||||
by_name = sort_by(animals, "name");
|
||||
```
|
||||
|
||||
### The Yield Operator
|
||||
@ -187,7 +187,7 @@ This can be useful when working on the command line but to make a script easier
|
||||
json = download("https://api.sampleapis.com/futurama/characters");
|
||||
from_json(json)
|
||||
-> select(input, "name");
|
||||
-> input.4
|
||||
-> get(input, 4)
|
||||
```
|
||||
|
||||
### Functions
|
||||
@ -201,7 +201,7 @@ say_hi = 'output "hi"';
|
||||
add_one = 'input + 1';
|
||||
|
||||
say_hi();
|
||||
assert_equal(add_one(3), 4);
|
||||
assert_eq(add_one(3), 4);
|
||||
```
|
||||
|
||||
This function simply passes the input to the shell's standard output.
|
||||
@ -217,8 +217,8 @@ organize them.
|
||||
math.add = 'input.0 + input.1';
|
||||
math.subtract = 'input.0 - input.1';
|
||||
|
||||
assert_equal(math.add(2, 2), 4);
|
||||
assert_equal(math.subtract(100, 1), 99);
|
||||
assert_eq(math.add(2, 2), 4);
|
||||
assert_eq(math.subtract(100, 1), 99);
|
||||
```
|
||||
|
||||
### Time
|
||||
|
@ -73,33 +73,6 @@ impl Tool for String {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Replace;
|
||||
|
||||
impl Tool for Replace {
|
||||
fn info(&self) -> ToolInfo<'static> {
|
||||
ToolInfo {
|
||||
identifier: "replace",
|
||||
description: "Replace all occurences of a substring in a string.",
|
||||
group: "collections",
|
||||
inputs: vec![ValueType::ListExact(vec![
|
||||
ValueType::String,
|
||||
ValueType::String,
|
||||
ValueType::String,
|
||||
])],
|
||||
}
|
||||
}
|
||||
|
||||
fn run(&self, argument: &Value) -> Result<Value> {
|
||||
let argument = self.check_type(argument)?.as_list()?;
|
||||
let target = argument[0].as_string()?;
|
||||
let to_remove = argument[1].as_string()?;
|
||||
let replacement = argument[2].as_string()?;
|
||||
let result = target.replace(to_remove, replacement);
|
||||
|
||||
Ok(Value::String(result))
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Count;
|
||||
|
||||
impl Tool for Count {
|
||||
|
@ -50,14 +50,13 @@ pub mod time;
|
||||
/// Master list of all tools.
|
||||
///
|
||||
/// This list is used to match identifiers with tools and to provide info to the shell.
|
||||
pub const TOOL_LIST: [&'static dyn Tool; 50] = [
|
||||
pub const TOOL_LIST: [&'static dyn Tool; 49] = [
|
||||
&collections::Count,
|
||||
&collections::CreateTable,
|
||||
&collections::Insert,
|
||||
&collections::Rows,
|
||||
&collections::Select,
|
||||
&collections::String,
|
||||
&collections::Replace,
|
||||
&collections::Transform,
|
||||
&collections::Where,
|
||||
&command::Bash,
|
||||
|
Loading…
Reference in New Issue
Block a user