str-expand: new capability, empty collection item (#9750)

I added a new capability to `bracoxide` which is for `brace expansion`
(it's almost like bash brace expressions).

Anyway, this change adds this capability:

`A{,B,C} | str expand`, returns:

```md
- A
- AB
- AC
```


`A{B,,C} | str expand`, returns:

```md
- AB
- A
- AC
```

`A{B,C,} | str expand`, returns:

```md
- AB
- AC
- A
```

Updated examples, according to the new feature.
This commit is contained in:
A. Taha Baki
2023-07-21 02:51:25 +03:00
committed by GitHub
parent 693cb5c142
commit c01f2ee0e9
3 changed files with 42 additions and 3 deletions

View File

@ -69,6 +69,45 @@ impl Command for SubCommand {
},)
},
Example {
description: "Collection may include an empty item. It can be put at the start of the list.",
example: "\"A{,B,C}\" | str expand",
result: Some(Value::List{
vals: vec![
Value::test_string("A"),
Value::test_string("AB"),
Value::test_string("AC"),
],
span: Span::test_data()
},)
},
Example {
description: "Empty item can be at the end of the collection.",
example: "\"A{B,C,}\" | str expand",
result: Some(Value::List{
vals: vec![
Value::test_string("AB"),
Value::test_string("AC"),
Value::test_string("A"),
],
span: Span::test_data()
},)
},
Example {
description: "Empty item can be in the middle of the collection.",
example: "\"A{B,,C}\" | str expand",
result: Some(Value::List{
vals: vec![
Value::test_string("AB"),
Value::test_string("A"),
Value::test_string("AC"),
],
span: Span::test_data()
},)
},
Example {
description: "Also, it is possible to use one inside another. Here is a real-world example, that creates files:",
example: "\"A{B{1,3},C{2,5}}D\" | str expand",