curl_transcode
Version:
Transcode cURL query to various programming languages
23 lines (19 loc) • 648 B
text/typescript
import path from "path";
import { CommandLineError } from "./error.ts";
export class CommandLine {
readonly sourceDirectory: string;
readonly targetDirectory: string;
constructor(sourceDirectory: string, targetDirectory: string) {
this.sourceDirectory = sourceDirectory;
this.targetDirectory = targetDirectory;
}
static fromProcessArguments(): CommandLine {
let command = path.basename(process.argv[0]);
if (process.argv.length !== 4) {
throw new CommandLineError(
`hint: ${command} <source_directory> <target_directory>`
);
}
return new CommandLine(process.argv[2], process.argv[3]);
}
}