Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/apps/interplane-forge/tools/bring/src/90main.om # omega-mv Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance. Brought by drakestapleton Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / apps / interplane-forge / tools / bring / src / 90main.om` 177 lines ยท 2992 bytes Raw Blame History 1 text tbring "bring" 2 text tget "get" 3 text twithdr "withdraw" 4 text tpack "pack" 5 text tunpack "unpack" 6 text tpatch "patch" 7 text tvarg "--version" 8 text tusage "usage: interplane bring [folder] | get | withdraw | patch [--base REF] [--title T] [--message-file F] [--yes] OWNER/REPO | pack | unpack " 9 text tconsent "Your project will be published on an open network called Radicle, through Interplane.\nPublishing is permanent: copies may stay on other computers even if you withdraw it later.\nType yes to publish it, anything else to stop:\n" 10 text ttty "/dev/tty" 11 text tyes "yes" 12 text tno "Nothing sent.\n" 13 note consent: q is printed, then one line from /dev/tty (never stdin): true only for exactly "yes" 14 fn consent q view uchar * to bool 15 say q 16 fd = pl_open ttty 4 0 17 if lt fd 0 18 ret false 19 end 20 b = new uchar 1 0 21 a = new uchar 3 0 22 n = ulong 0 23 ok = true 24 while true bound `9223372036854775807` 25 r = read int fd b 0 1 26 if eq r -4 27 continue 28 end 29 if le r 0 30 ok = false 31 break 32 end 33 if eq get b 0 10 34 break 35 end 36 if lt n 3 37 put a n get b 0 38 else 39 ok = false 40 end 41 n = add n 1 42 end 43 pl_close int fd 44 ret and ok and eq n 3 beq a tyes 45 end 46 fn prepare folder view uchar * to void 47 r = pl_cd folder 48 if lt r 0 49 die terrdir 50 end 51 tmpsetup 52 put grecfd 0 topen tfiles 2 53 put gspool 0 topen tkeep 2 54 walk part tdot 0 0 55 pl_close get grecfd 0 56 pl_close get gspool 0 57 sortfiles 58 mkname 59 say tname 60 wname 1 61 say tnl 62 say tcnt 63 sayd get gcount 0 64 say tnl 65 say tbytes 66 sayd get gbytes 0 67 say tnl 68 end 69 fn getarg i ulong b edit uchar * to ulong 70 n = pl_arg i b 71 if lt n 0 72 die tusage 73 end 74 ret ulong n 75 end 76 fn main to int 77 cmd = new uchar 4096 0 78 folder = new uchar 4096 0 79 archivep = new uchar 4096 0 80 ac = pl_argc 81 if lt ac 2 82 die tusage 83 end 84 n = getarg 1 cmd 85 if beq part cmd 0 n tvarg 86 say tver 87 ret 0 88 end 89 if beq part cmd 0 n tpatch 90 ret patchflow ulong ac 91 end 92 if beq part cmd 0 n tunpack 93 if ne ac 4 94 die tusage 95 end 96 an = getarg 2 archivep 97 fnl = getarg 3 folder 98 fd = pl_open part archivep 0 an 0 0 99 if lt fd 0 100 die terrio 101 end 102 tarwalk int fd false 103 r = pl_seek int fd 0 104 r = pl_mkdir part folder 0 fnl 448 105 if ne r 0 106 die texists 107 end 108 r = pl_cd part folder 0 fnl 109 if lt r 0 110 die terrdir 111 end 112 tarwalk int fd true 113 pl_close int fd 114 ret 0 115 end 116 if beq part cmd 0 n tpack 117 if ne ac 4 118 die tusage 119 end 120 fnl = getarg 2 folder 121 an = getarg 3 archivep 122 fd = pl_open part archivep 0 an 3 384 123 if lt fd 0 124 die texists 125 end 126 prepare part folder 0 fnl 127 archive int fd 128 pl_close int fd 129 cleanup 130 ret 0 131 end 132 if beq part cmd 0 n tbring 133 if gt ac 3 134 die tusage 135 end 136 fnl = ulong 1 137 put folder 0 46 138 if eq ac 3 139 fnl = getarg 2 folder 140 end 141 prepare part folder 0 fnl 142 if not consent tconsent 143 say tno 144 cleanup 145 ret 1 146 end 147 bringflow part folder 0 fnl 148 cleanup 149 ret 0 150 end 151 if beq part cmd 0 n tget 152 if ne ac 3 153 die tusage 154 end 155 fnl = getarg 2 folder 156 tmpsetup 157 getflow part folder 0 fnl 158 cleanup 159 ret 0 160 end 161 if beq part cmd 0 n twithdr 162 if ne ac 3 163 die tusage 164 end 165 fnl = getarg 2 folder 166 tmpsetup 167 if not wdflow part folder 0 fnl 168 say tno 169 cleanup 170 ret 1 171 end 172 cleanup 173 ret 0 174 end 175 die tusage 176 ret 1 177 end