This commit is contained in:
despiegk 2024-01-13 14:42:27 +03:00
parent cb15e19bab
commit 66c12f607d
Signed by: despiegk
GPG Key ID: 99E4E1492F73BC18
3 changed files with 23 additions and 11 deletions

View File

@ -25,16 +25,14 @@ export def git_configure [] {
export def git_clone [ name: string url: string , --reset=false , --pull=false ] string { export def git_clone [ name: string url: string , --reset=false , --pull=false ] string {
print $"git clone '($url)'"
git_configure git_configure
let $dest = $"($env.BASE)/code/($name)" let $dest = $"($env.BASE)/code/($name)"
if $reset { if $reset {
print $"remove git dir: ($dest)" print $"remove git dir: ($dest)"
rm -f $dest rm -f $dest
} }
if ($dest | path exists) and ( ( ls $dest | length ) > 0 ) { if ($dest | path exists) and ( ( ls $dest | length ) > 0 ) {
mkdir $dest mkdir $dest
cd $dest cd $dest
if $pull == true { if $pull == true {
@ -42,7 +40,7 @@ export def git_clone [ name: string url: string , --reset=false , --pull=false ]
git pull git pull
} }
} else { } else {
print $"git clone execute" print $"git clone '($url)'"
cd $"($env.BASE)/code" cd $"($env.BASE)/code"
git clone --depth 1 --no-single-branch $url git clone --depth 1 --no-single-branch $url
} }

View File

@ -1,5 +1,6 @@
use git.nu use git.nu
use download.nu use download.nu
use runonce.nu
def sshagent_loaded [ ] bool { def sshagent_loaded [ ] bool {
return ( (ssh-add -l | lines -s | length) > 0 ) return ( (ssh-add -l | lines -s | length) > 0 )
@ -15,9 +16,13 @@ def url_crystal [] {
} }
} }
export def clone_crystal [ --reset=false , --pull=false ] string { export def install_crystal [ --reset=false , --pull=false ] string {
let $vpath = install_v
rm -f $"($env.BASE)/bin/v"
ln -s $"($vpath)/v" $"($env.BASE)/bin/v"
let $url = url_crystal let $url = url_crystal
let $r = git git_clone crystallib $url let $r = git git_clone crystallib $url
# ln -s $"($r)/"
return $r return $r
} }
@ -35,8 +40,15 @@ export def clone_nuscripts [ --reset=false , --pull=false ] string {
} }
} }
export def install_v [ --reset=false , --pull=false ] string {
let $r = git git_clone v "https://github.com/vlang/v"
runonce run 'install_v' {
cd $r
print "will compile V, can take a long while."
^make
} --reset $reset
return $r
}
def url_mycelium [] string { def url_mycelium [] string {
let $os = $nu.os-info.name let $os = $nu.os-info.name

View File

@ -7,8 +7,10 @@ export def "run" [
--reset: bool = false --reset: bool = false
#means we redo the command #means we redo the command
] { ] {
mkdir $"($env.HOME)/hero/done/)"
let state_file = [ $env.HOME 'hero' done ('nu_done_' + $name) ] | path join let $state_dir = $"($env.BASE/done)"
mkdir $state_dir
let $state_file = $"($state_dir)/nu_done_($name)"
if ($reset or (not ($state_file | path exists ) ) ) { if ($reset or (not ($state_file | path exists ) ) ) {
let start = date now let start = date now
# let result = do $task # let result = do $task
@ -28,7 +30,7 @@ export def "run" [
export def "reset" [ export def "reset" [
prefix: string prefix: string
] { ] {
ls $"($env.HOME)/hero/done/nu_done*" | each { |it| rm $it.name} ls $"($env.BASE)/done/nu_done*" | each { |it| rm $it.name}
} }
@ -43,7 +45,7 @@ export def "reset" [
# --reset: bool = false # --reset: bool = false
# #means we redo the command # #means we redo the command
# ] { # ] {
# let state_file = [ $env.HOME 'hero' ('nu_done_' + $name) ] | path join # let state_file = [ $env.BASE 'hero' ('nu_done_' + $name) ] | path join
# if ($reset or (not ($state_file | path exists ) ) ) { # if ($reset or (not ($state_file | path exists ) ) ) {
# let start = date now # let start = date now
# # let result = do $task # # let result = do $task