Skip to content

Commit e3f7e98

Browse files
committed
chore: wip
chore: wip chore: wip
1 parent 7c3881a commit e3f7e98

File tree

4 files changed

+80
-0
lines changed

4 files changed

+80
-0
lines changed

pkgx.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ dependencies:
88
npmjs.com: ^9.7.2 # can soon be removed when Bun-native support is released
99
redis.io: ^7.0.11
1010
sqlite.org: ^3.42.0
11+
dns.lookup.dog: ^0.1.0
1112
stedolan.github.io/jq: ^1.7

storage/framework/.stacks/core/buddy/src/cli.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ async function main() {
3333
cmd.domains(buddy)
3434
cmd.fresh(buddy)
3535
cmd.install(buddy)
36+
cmd.dns(buddy)
3637
// cmd.lint(buddy)
3738
cmd.release(buddy)
3839
// cmd.make(buddy)
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import { ExitCode } from '@stacksjs/types'
2+
import type { CLI } from '@stacksjs/types'
3+
import { config } from '@stacksjs/config'
4+
import { runCommand } from '@stacksjs/cli'
5+
6+
// import { Action } from '@stacksjs/enums'
7+
// import { runAction } from '@stacksjs/actions'
8+
9+
type DnsOptions = {
10+
query?: string
11+
type?: string
12+
nameserver?: string
13+
class?: string
14+
udp?: boolean
15+
tcp?: boolean
16+
tls?: boolean
17+
https?: boolean
18+
short?: boolean
19+
json?: boolean
20+
pretty?: boolean
21+
p?: boolean // short for pretty
22+
verbose?: boolean
23+
}
24+
25+
export function dns(buddy: CLI) {
26+
const descriptions = {
27+
dns: 'Lists the DNS records for a domain',
28+
query: 'Host name or IP address to query',
29+
type: 'Type of the DNS record being queried (A, MX, NS…)',
30+
nameserver: 'Address of the nameserver to send packets to',
31+
class: 'Network class of the DNS record being queried (IN, CH, HS)',
32+
udp: 'Use the DNS protocol over UDP',
33+
tcp: 'Use the DNS protocol over TCP',
34+
tls: 'Use the DNS-over-TLS protocol',
35+
https: 'Use the DNS-over-HTTPS protocol',
36+
short: 'Short mode: display nothing but the first result',
37+
json: 'Display the output as JSON',
38+
pretty: 'Display the output as JSON in a pretty format',
39+
verbose: 'Enable verbose output',
40+
}
41+
42+
buddy
43+
.command('dns [domain]', descriptions.dns)
44+
.option('-q, --query <query>', descriptions.query)
45+
.option('-t, --type <type>', descriptions.type, { default: 'ANY' })
46+
.option('-n, --nameserver <nameserver>', descriptions.nameserver)
47+
.option('--class <class>', descriptions.nameserver)
48+
// transport options
49+
.option('-U, --udp', descriptions.udp)
50+
.option('-T, --tcp', descriptions.tcp)
51+
.option('-S, --tls', descriptions.tls)
52+
.option('-H, --https', descriptions.https)
53+
// output options
54+
.option('-1, --short', descriptions.short, { default: false })
55+
.option('-J, --json', descriptions.json, { default: false })
56+
.option('-p, --pretty', descriptions.pretty, { default: true })
57+
.option('--verbose', descriptions.verbose, { default: false })
58+
.action(async (domain: string | undefined, options: DnsOptions) => {
59+
let prettyOutput = false
60+
61+
if (options.json && options.pretty)
62+
prettyOutput = true
63+
64+
delete options.pretty
65+
delete options.p
66+
67+
// Convert options object to command-line options string
68+
const optionsString = Object.entries(options)
69+
.filter(([key, value]) => key !== '--' && key.length > 1 && value !== false) // filter out '--' key and short options
70+
.map(([key, value]) => `--${key} ${value}`)
71+
.join(' ')
72+
73+
await runCommand(`dog ${domain || config.app.url } ${optionsString}`)
74+
75+
process.exit(ExitCode.Success)
76+
})
77+
}

storage/framework/.stacks/core/buddy/src/commands/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export * from './create'
88
export * from './deploy'
99
export * from './dev'
1010
export * from './domains'
11+
export * from './dns'
1112
export * from './example'
1213
export * from './fresh'
1314
export * from './generate'

0 commit comments

Comments
 (0)