Files
bare-operating-system/packages/bare-os-seeder/kernel/bin/login
T
Raven Scott 342b6040fe
CI / test (push) Successful in 9m48s
Update
2026-04-03 02:49:18 -04:00

31 lines
860 B
Bash

/** Shared helpers for drive-resident /bin scripts (prepended before each command). */
function bareStdin(ctx) {
return typeof ctx.shellStdin === 'string' ? ctx.shellStdin : ''
}
async function run(ctx, argv) {
const rest = argv.slice(1)
let createNew = false
if (rest[0] === '--new') {
createNew = true
rest.shift()
}
const passphrase = rest.join(' ')
if (!passphrase) {
ctx.console.error('usage: login [--new] <passphrase>')
return
}
const reg = ctx.applyRegister
const unlock = ctx.applyUnlock
if (typeof reg !== 'function' || typeof unlock !== 'function') {
ctx.console.error('login: not supported in this environment')
return
}
try {
if (createNew) await reg.call(ctx, passphrase)
else await unlock.call(ctx, passphrase)
} catch (err) {
ctx.console.error(err?.message ?? String(err))
}
}