mirror of
https://github.com/Cian-H/dotfiles.git
synced 2026-04-08 20:27:59 +01:00
Changed . token to _dot
This change allows the dotfiles to work with chezmoi (e.g: on windows) and improves grepability with neovim/telescope
This commit is contained in:
5
dot_config/nushell/nu_scripts/modules/parsing/README.md
Normal file
5
dot_config/nushell/nu_scripts/modules/parsing/README.md
Normal file
@@ -0,0 +1,5 @@
|
||||
# Parsing Scripts
|
||||
|
||||
### Definition
|
||||
|
||||
These scripts should be used to demonstrate how to parse any file format, including `json`, `csv`, etc. Also, perhaps parsing of `external` commands. For example, on Windows, perhaps we could wrap `ipconfig.exe` so that the output was more nushell friendly.
|
||||
@@ -0,0 +1,18 @@
|
||||
[
|
||||
{
|
||||
"name": "Brunello Cucinelli",
|
||||
"shoes": [
|
||||
{ "name": "tasselled black low-top lace-up", "price": 1000 },
|
||||
{ "name": "tasselled green low-top lace-up", "price": 1100 },
|
||||
{ "name": "plain beige suede moccasin", "price": 950 },
|
||||
{ "name": "plain olive suede moccasin", "price": 1050 }
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Gucci",
|
||||
"shoes": [
|
||||
{ "name": "red leather laced sneakers", "price": 800 },
|
||||
{ "name": "black leather laced sneakers", "price": 900 }
|
||||
]
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,21 @@
|
||||
def look_for [word] {
|
||||
open sample_andres.json |
|
||||
flatten |
|
||||
flatten |
|
||||
insert comp {
|
||||
get shoes_name |
|
||||
split row " " |
|
||||
enumerate | each {
|
||||
[[idx, loc]; [$in.index, ($in.item | str index-of $word)]]
|
||||
} | flatten
|
||||
} |
|
||||
flatten |
|
||||
where comp.loc >= 0 |
|
||||
flatten |
|
||||
update idx { $in + 1 } |
|
||||
reject name price loc |
|
||||
rename nameWords targetWordIndex
|
||||
}
|
||||
|
||||
print (look_for "leather" | to json --indent 4)
|
||||
print (look_for "low-top" | to json --indent 4)
|
||||
Reference in New Issue
Block a user