all repos — min @ 83cf449c59c9098a9a154f10d11c62a6b769b52f

A small but practical concatenative programming language.

tasks/ssh.min

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
#!/usr/bin/env min

".env.yml" fread from-yaml :env
"min.yml" fread from-yaml :config

env /ssh-host :host
env /ssh-h3rald-dir :h3rald-dir
env /ssh-min-dir :min-dir
"Min_DeveloperGuide.htm" :guide-file
"$#/assets/min/$#" (h3rald-dir guide-file) =% :h3rald-guide
"cd " min-dir suffix :min-cd
"cd " h3rald-dir suffix :h3rald-cd
"$#/contents/min.md" (min-dir) =% :min-md
"min.yml" fread from-yaml :config
config /version :min-version

"version:\\s+\\d+\\.\\d+\\.\\d+" :min-v-reg
"version: $#" (min-version) =% :min-v-rep

; Helpers
(
  :prog (prog which "" ==) ("$# is not available" (prog) =% error 1 exit) when
) :required
(
  "export PATH=~/bin:~/.nimble/bin:$PATH"
  min-cd
) :init

{}
(
  ; This should be executed on the remote host
  guide-file h3rald-guide cp
  min-md fread "s/$#/$#/m" (min-v-reg min-v-rep) =% regex min-md fwrite
) :h3rald-update
(
  "ssh" required
  "ssh - build ($#)" (host) =% notice
  ( 
    init
    "min run ssh:h3rald-update"
    h3rald-cd
    "git pull"
    "hastysite build"
  ) => "; " join :cmds
  "ssh $# \"$#\"" (host cmds) =% !!
) %h3rald
(
  "ssh" required
  "ssh - build ($#)" (host) =% notice
  ( 
    init
    "git pull"
    "nifty upgrade"
    "min run build" 
    "min run build:guide"
    "min run build:site"
  ) => "; " join :cmds
  "ssh $# \"$#\"" (host cmds) =% !!
) %build
+ssh-tasks