mailer/cli.ts

40 lines
962 B
TypeScript
Raw Normal View History

2024-03-29 16:25:29 +01:00
import config from './deno.json' with { type: 'json' }
2024-07-15 12:10:57 +02:00
import { Command } from '@cliffy/command'
2024-07-15 14:58:15 +02:00
import { UpgradeCommand } from '@cliffy/command/upgrade'
import { JsrProvider } from '@cliffy/command/upgrade/provider/jsr'
2024-03-29 16:30:33 +01:00
import { cmd as send } from './cli/send.ts'
2024-04-03 17:56:38 +02:00
import { cmd as preview } from './cli/preview.ts'
2024-03-29 16:25:29 +01:00
2024-07-15 14:58:15 +02:00
const upgradeCommand = new UpgradeCommand({
args: [
'--allow-read',
'--allow-env',
'--allow-net=0.0.0.0',
'--allow-sys=osRelease,networkInterfaces',
'--allow-run=/usr/sbin/sendmail,whoami',
'--name=cohamail',
],
provider: [
new JsrProvider({
package: config.name as `@${string}/${string}`,
main: 'cli',
}),
],
})
2024-03-29 16:25:29 +01:00
const cli = new Command()
.name('cohamail')
.description('Mail cli for coh@bit.')
.version(config.version)
2024-04-03 17:56:38 +02:00
.command('preview', preview)
2024-03-29 16:25:29 +01:00
.command('send', send)
2024-07-15 14:58:15 +02:00
.command('upgrade', upgradeCommand)
2024-03-29 16:25:29 +01:00
if (import.meta.main) {
if (Deno.args.length) {
cli.parse(Deno.args)
} else {
cli.showHelp()
}
}