1
Fork 0
mirror of https://github.com/RGBCube/nu_scripts synced 2025-08-02 23:27:45 +00:00

refactor: (#418)

* refactor:  move in one commit

Eveything in modules should probably be changed to `exported` defs.
The idea is to move everything first to keep proper history.

* refactor: 📝 add modules readme (wip)

* refactor:  small move

* refactor: 📝 changed nestring, updated modules readme

* refactor: 📝 to document or not to document

* fix: 🐛 themes

replaced the template to use `main` and regenerated them
from lemnos themes.

* Revert "fix: 🐛 themes"

This reverts commit 4918d3633c8d2d81950a0ed0cfd9eb84241bc886.

* refactor:  introduce sourced

- Created a source `root` in which sourcable demos are stored.
  Some might get converted to modules later on.
- Moved some files to bin too.

* fix: 🐛 fehbg.nu

* fix: 🐛 modules/after.nu

* moved some other stuff around

---------

Co-authored-by: Darren Schroeder <343840+fdncred@users.noreply.github.com>
This commit is contained in:
Mel Massadian 2023-04-26 00:56:25 +02:00 committed by GitHub
parent 382696cd21
commit c47ccd42b8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
128 changed files with 185 additions and 12 deletions

View file

@ -0,0 +1,59 @@
# Returns a list of full paths starting from root, to the path given
#
#
# walk '/home/user/projects';
# > [
# > '/home/',
# > '/home/user/',
# > '/home/user/projects/',
# > ]
#
export def "path walk" [
path: any
] {
let list = ($path | path expand | path split);
$list | each -n { |$part| (
$list | first ($part.index + 1) | path join;
)}
}
# Returns true if 'subfolder' is found along the path of 'folder', with a given type
export def "path check-sub" [
folder: any,
subfolder: string,
--type: string
] {
(ls -a $folder
| where (
($type == $nothing or $it.type == $type)
and ($it.name | path basename) == $subfolder
)
| length
) > 0;
}
# Walks the path along 'folder', and returns the path of the first subfolder found, or nothing if the subfolder was not found.
#
# path find-sub '/home/user/projects/code' '.venv';
# > /home/user/projects/.venv
export def "path find-sub" [
folder: any,
subfolder: string,
--type: string
] {
let paths = path walk $folder;
let paths = ( $paths
| where (
path check-sub $it $subfolder --type $type
)
);
if ($paths != $nothing) and ($paths | length) > 0 {
[ ($paths | first), $subfolder ] | path join
}
}