Skip to content

Instantly share code, notes, and snippets.

@Dzejkop
Created March 11, 2023 12:45
Show Gist options
  • Save Dzejkop/94ce3cea010eb2e25b952fa8fd7bc70f to your computer and use it in GitHub Desktop.
Save Dzejkop/94ce3cea010eb2e25b952fa8fd7bc70f to your computer and use it in GitHub Desktop.
Nu Scripts
def findMod [path: path] {
ls -a $path | where type == 'file' | where name =~ 'mod.rs' | select name | each {|e| handleModFile $e.name }
if ($path | path exists) {
ls -a $path | where type == 'dir' | select name | each {|e| findMod ($path | path join $e.name) }
}
}
def handleModFile [path: path] {
let d = ($path | path dirname)
let f = ([$d ".rs"] | str join)
mv $path $f
if isEmpyDir $d {
rm -rf $d
}
}
def isEmpyDir [path: path] {
(ls -a $path | length) == 0
}
def main [path: path] {
findMod $path
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment