mirror of
https://github.com/cupcakearmy/cryptgeon.git
synced 2025-09-09 18:50:39 +00:00
cli
This commit is contained in:
@@ -24,7 +24,6 @@ export async function download(url: URL) {
|
||||
exit('No files found in note')
|
||||
return
|
||||
}
|
||||
console.log(files)
|
||||
const { names } = await inquirer.prompt([
|
||||
{
|
||||
type: 'checkbox',
|
||||
@@ -50,7 +49,7 @@ export async function download(url: URL) {
|
||||
await access(filename, constants.R_OK)
|
||||
filename = resolve(`${Date.now()}-${file.name}`)
|
||||
} catch {}
|
||||
await writeFile(filename, new Uint8Array(await file.contents.arrayBuffer()))
|
||||
await writeFile(filename, file.contents)
|
||||
console.log(`Saved: ${basename(filename)}`)
|
||||
})
|
||||
)
|
||||
|
@@ -2,6 +2,7 @@
|
||||
|
||||
import { Argument, Option, program } from '@commander-js/extra-typings'
|
||||
import { setBase, status } from '@cryptgeon/shared'
|
||||
import prettyBytes from 'pretty-bytes'
|
||||
|
||||
import { download } from './download.js'
|
||||
import { parseFile, parseNumber } from './parsers.js'
|
||||
@@ -37,10 +38,14 @@ program
|
||||
.action(async (options) => {
|
||||
setBase(options.server)
|
||||
const response = await status()
|
||||
for (const key of Object.keys(response)) {
|
||||
if (key.startsWith('theme_')) delete response[key as keyof typeof response]
|
||||
const formatted = {
|
||||
...response,
|
||||
max_size: prettyBytes(response.max_size),
|
||||
}
|
||||
console.table(response)
|
||||
for (const key of Object.keys(formatted)) {
|
||||
if (key.startsWith('theme_')) delete formatted[key as keyof typeof formatted]
|
||||
}
|
||||
console.table(formatted)
|
||||
})
|
||||
|
||||
const send = program.command('send')
|
||||
|
@@ -1,10 +1,10 @@
|
||||
import { InvalidArgumentError, InvalidOptionArgumentError } from '@commander-js/extra-typings'
|
||||
import { accessSync, constants } from 'node:fs'
|
||||
import path from 'node:path'
|
||||
import { resolve } from 'node:path'
|
||||
|
||||
export function parseFile(value: string, before: string[] = []) {
|
||||
try {
|
||||
const file = path.resolve(value)
|
||||
const file = resolve(value)
|
||||
accessSync(file, constants.R_OK)
|
||||
return [...before, file]
|
||||
} catch {
|
||||
|
@@ -3,7 +3,7 @@ import { readFile, stat } from 'node:fs/promises'
|
||||
import { basename } from 'node:path'
|
||||
|
||||
import { Adapters, BASE, create, FileDTO, Note } from '@cryptgeon/shared'
|
||||
import mime from 'mime'
|
||||
import * as mime from 'mime'
|
||||
import { AES, Hex, TypedArray } from 'occulto'
|
||||
|
||||
import { exit } from './utils.js'
|
||||
@@ -32,9 +32,9 @@ export async function uploadFiles(paths: string[], options: UploadOptions) {
|
||||
return {
|
||||
name: basename(path),
|
||||
size: stats.size,
|
||||
contents: new Blob([data]) as FileDTO['contents'],
|
||||
contents: data,
|
||||
type,
|
||||
}
|
||||
} satisfies FileDTO
|
||||
})
|
||||
)
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
import process from 'node:process'
|
||||
import { exit as exitNode } from 'node:process'
|
||||
|
||||
export function exit(message: string) {
|
||||
console.error(message)
|
||||
process.exit(1)
|
||||
exitNode(1)
|
||||
}
|
||||
|
Reference in New Issue
Block a user