mirror of
https://github.com/RGBCube/nu_scripts
synced 2025-08-01 06:37:46 +00:00
work on the nu-themes
make script (#905)
i was mostly having fun there 😋 cc/ @NotTheDr01ds ## changes - using some colors for the logging - slight refactor of the main, i.e. i build a `table<name: string, source: string>` of themes and then iterate over it and call `make-theme $t.name $t.source`, thus getting rid of the twin pipelines - i also build a `table<name: string, source: string>` of failing themes, to show them at the end ## reviewing i think the best to review this is - go to `themes/` - remove any copy of the `lemnos/` directory - run `./src/make.nu` twice and see the output 😉
This commit is contained in:
parent
995c1ea21c
commit
ecfbad67b9
1 changed files with 48 additions and 26 deletions
|
@ -15,6 +15,18 @@ let CUSTOM_SOURCE = {
|
||||||
|
|
||||||
let themes_dir = ($current_dir | path join "../nu-themes")
|
let themes_dir = ($current_dir | path join "../nu-themes")
|
||||||
|
|
||||||
|
def info [msg: string, --no-newline (-n)] {
|
||||||
|
print --no-newline=$no_newline $"(ansi green)[INFO](ansi reset) ($msg)"
|
||||||
|
}
|
||||||
|
|
||||||
|
def err [msg: string, --no-newline (-n)] {
|
||||||
|
print --no-newline=$no_newline $"(ansi red_bold)[ERR](ansi reset) ($msg)"
|
||||||
|
}
|
||||||
|
|
||||||
|
def warn [msg: string, --no-newline (-n)] {
|
||||||
|
print --no-newline=$no_newline $"(ansi yellow)[WARNING](ansi reset) ($msg)"
|
||||||
|
}
|
||||||
|
|
||||||
# For lemnos themes, create the color_config from the lemnos theme
|
# For lemnos themes, create the color_config from the lemnos theme
|
||||||
# definition.
|
# definition.
|
||||||
# Custom Nushell themes should be defined in themes/src/custom-nu-themes
|
# Custom Nushell themes should be defined in themes/src/custom-nu-themes
|
||||||
|
@ -205,36 +217,46 @@ def make_theme [ name: string, origin: string = "lemnos" ] {
|
||||||
def main [] {
|
def main [] {
|
||||||
mkdir $themes_dir
|
mkdir $themes_dir
|
||||||
|
|
||||||
try { git clone $LEMNOS_SOURCE.remote_repo $LEMNOS_SOURCE.local_repo }
|
if ($LEMNOS_SOURCE.local_repo | path exists) {
|
||||||
|
warn "local copy of Lemnos' themes already exists"
|
||||||
ls $LEMNOS_SOURCE.dir
|
info "updating local copy"
|
||||||
| get name
|
|
||||||
| path parse
|
|
||||||
| get stem
|
|
||||||
| each {|theme|
|
|
||||||
print $"Converting ($theme)"
|
|
||||||
try {
|
try {
|
||||||
make_theme $theme
|
git -C $LEMNOS_SOURCE.local_repo pull origin master
|
||||||
} catch {|e|
|
} catch {
|
||||||
print -e $"Error converting ($theme)"
|
err "failed updating local copy"
|
||||||
print -e $e.debug
|
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
| ignore
|
info "cloning Lemnos' themes"
|
||||||
|
|
||||||
ls $CUSTOM_SOURCE.dir
|
|
||||||
| get name
|
|
||||||
| path parse
|
|
||||||
| get stem
|
|
||||||
| each {|theme|
|
|
||||||
print $"Converting ($theme)"
|
|
||||||
try {
|
try {
|
||||||
make_theme $theme "custom"
|
git clone $LEMNOS_SOURCE.remote_repo $LEMNOS_SOURCE.local_repo
|
||||||
} catch {|e|
|
} catch {
|
||||||
print -e $"Error converting ($theme)"
|
error make --unspanned { msg: "failed cloning local copy" }
|
||||||
print -e $e.debug
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
print "all done"
|
let themes: table<name: string, source: string> = (
|
||||||
|
ls $LEMNOS_SOURCE.dir
|
||||||
|
| insert source "lemnos"
|
||||||
|
| append (ls $CUSTOM_SOURCE.dir | insert source "custom")
|
||||||
|
| update name { path parse | get stem }
|
||||||
|
| select name source
|
||||||
|
)
|
||||||
|
|
||||||
|
let failed = $themes | each { |t|
|
||||||
|
info -n $"Converting ($t.name) \r"
|
||||||
|
try {
|
||||||
|
make_theme $t.name $t.source
|
||||||
|
} catch { |e|
|
||||||
|
err $"Converting ($t.name) failed: ($e.msg)"
|
||||||
|
$t
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
print ''
|
||||||
|
if not ($failed | is-empty) {
|
||||||
|
warn "The following themes have failed:"
|
||||||
|
print $failed
|
||||||
|
} else {
|
||||||
|
print "all done"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue