-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7db2c68
commit 7ba3e90
Showing
7 changed files
with
77 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env node | ||
|
||
import('../dist/esm/retroload-convert.js'); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env node | ||
|
||
import('../dist/esm/retroload-tokenize.js'); | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#!/usr/bin/env node | ||
|
||
import {ConverterManager, Exception, Logger, version as libVersion} from 'retroload-lib'; | ||
import {Command} from 'commander'; | ||
import {version as cliVersion} from './version.js'; | ||
import {readFile, writeFile} from './Utils.js'; | ||
|
||
main() | ||
.catch((err) => { | ||
Logger.error(err as string); | ||
}); | ||
|
||
async function main() { | ||
// const formatNames = AdapterManager.getAllAdapters().map((a) => a.internalName); | ||
// formatNames.sort(); | ||
const program = (new Command()) | ||
.name('retroload-convert') | ||
.description('Convert raw data into tape archive formats. (EXPERIMENTAL!)') | ||
.argument('infile', 'Path to file to convert') | ||
.allowExcessArguments(false) | ||
.option('-o <outfile>', 'Path to file to write') | ||
.option('-f <format>', 'Name of format to create') | ||
.option('-l, --loglevel <loglevel>', 'Verbosity of log output', '1') | ||
.version(`retroload: ${cliVersion}\nretroload-lib: ${libVersion}`) | ||
.showHelpAfterError(); | ||
// Options defined in adapters/encoders | ||
|
||
/* | ||
const allOptions = AdapterManager.getAllOptions(); | ||
allOptions.sort((a, b) => a.common && !b.common ? -1 : 0); | ||
for (const option of allOptions) { | ||
program.addOption(new Option(getCommanderFlagsString(option), option.description).hideHelp()); | ||
} | ||
*/ | ||
program.parse(); | ||
|
||
const options = program.opts(); | ||
const infile = program.args[0]; | ||
const outfile = options['o'] as string; // TODO: fix type stuff; let converter propose new filename ((input.bin).cas)? | ||
Logger.setVerbosity(parseInt(typeof options['loglevel'] === 'string' ? options['loglevel'] : '1', 10)); | ||
const inputBa = readFile(infile); | ||
const format: string = options['f'] as string; // TODO: fix type stuff | ||
|
||
Logger.debug(`Processing ${infile}...`); | ||
|
||
try { | ||
const outputBa = ConverterManager.convert(inputBa, format, options); | ||
writeFile(outfile, outputBa); | ||
} catch (e) { | ||
if (e instanceof Exception.UsageError) { | ||
Logger.error(e.message); | ||
process.exit(1); | ||
} else { | ||
throw e; // show full stack trace for unexpected errors | ||
} | ||
} | ||
} | ||
|
||
/* | ||
function getCommanderFlagsString(optionDefinition: PublicOptionDefinition) { | ||
return optionDefinition.type !== 'text' || optionDefinition.argument === undefined ? `--${optionDefinition.name}` : `--${optionDefinition.name} <${optionDefinition.argument}>`; | ||
} | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters