feat: update ssh-verify.ts, wget.ts

This commit is contained in:
2025-01-19 16:29:43 +08:00
parent 27111b421f
commit 86d2b0b3f6
3 changed files with 13 additions and 12 deletions

View File

@@ -3,7 +3,7 @@
import { parseArgs } from "jsr:@std/cli/parse-args";
import {
log,
} from "https://hatter.ink/script/fetch/library/deno-commons-mod.ts?202401191623";
} from "https://hatter.ink/script/fetch/library/deno-commons-mod.ts?202501191623";
import {
fetchKeys,
SshKey,

View File

@@ -4,14 +4,15 @@
// - https://docs.deno.com/examples/command_line_arguments/
// - https://jsr.io/@chiba/wget/1.0.0/mod.ts
import {parseArgs} from "jsr:@std/cli/parse-args";
import { parseArgs } from "jsr:@std/cli/parse-args";
import {
clearLastLine,
formatHumanTime,
formatPercent,
formatSize2,
log,
printLastLine,
} from "https://hatter.ink/script/fetch/library/deno-commons-mod.ts?202401191305";
} from "https://hatter.ink/script/fetch/library/deno-commons-mod.ts?202501191305";
function getOutputFilename(filename: string): string {
const original = filename;
@@ -55,7 +56,7 @@ const flags = parseArgs(Deno.args, {
});
if (args.length === 0) {
console.log(`wget.ts --help for help`);
log.info(`wget.ts --help for help`);
Deno.exit(1);
}
if (flags.help) {
@@ -66,7 +67,7 @@ wget.ts [--proxy socks5h://ip:port] [--no-proxy] [--output filename] <URL>`);
}
if (flags._.length === 0) {
console.log("Require URL.");
log.error("Require URL.");
Deno.exit(1);
}
@@ -76,7 +77,7 @@ const outputFilename = flags.output || getOutputFilenameFromUrl(url);
const startTime = new Date().getTime();
let totalLength: number = -2;
console.log(`Start download file: ${url} --> ${outputFilename}`);
log.info(`Start download file: ${url} --> ${outputFilename}`);
const stateFileInterVal = setInterval(async () => {
const costTime = new Date().getTime() - startTime;
@@ -104,7 +105,7 @@ let init = undefined;
const noProxy = flags["no-proxy"];
const proxy = flags.proxy || getEnvironmentProxy();
if (proxy && !noProxy) {
console.log(`Using proxy: ${proxy}`);
log.info(`Using proxy: ${proxy}`);
init = {
client: Deno.createHttpClient({
proxy: {
@@ -130,7 +131,7 @@ await clearLastLine();
const costTime = new Date().getTime() - startTime;
const fileInfo = await Deno.stat(outputFilename);
const fileSize = fileInfo.size;
console.log(
log.success(
`Download finished, size: ${formatSize2(fileSize)}, time: ${
formatHumanTime(costTime)
}`,