mirror of
https://github.com/davidgiven/fluxengine.git
synced 2025-10-31 11:17:01 -07:00
Split the read and write commands up to make the command list a bit more
manageable.
This commit is contained in:
@@ -33,102 +33,83 @@ struct Command
|
|||||||
std::string help;
|
std::string help;
|
||||||
};
|
};
|
||||||
|
|
||||||
static Command commands[] =
|
static command_cb mainRead;
|
||||||
|
static command_cb mainWrite;
|
||||||
|
|
||||||
|
static std::vector<Command> commands =
|
||||||
{
|
{
|
||||||
{
|
{ "erase", mainErase, "Permanently but rapidly erases some or all of a disk." },
|
||||||
"erase", mainErase,
|
{ "inspect", mainInspect, "Low-level analysis and inspection of a disk." },
|
||||||
"Permanently but rapidly erases some or all of a disk."
|
{ "rpm", mainRpm, "Measures the disk rotational speed.", },
|
||||||
},
|
{ "seek", mainSeek, "Moves the disk head.", },
|
||||||
{
|
{ "testbulktransport", mainTestBulkTransport, "Measures your USB bandwidth.", },
|
||||||
"inspect", mainInspect,
|
{ "upgradefluxfile", mainUpgradeFluxFile, "Upgrades a flux file from a previous version of this software.", },
|
||||||
"Low-level analysis and inspection of a disk."
|
{ "read", mainRead, "Reads a disk, producing a sector image.", },
|
||||||
},
|
{ "write", mainWrite, "Writes a sector image to a disk.", },
|
||||||
{
|
{ "writeflux", mainWriteFlux, "Writes a raw flux file. Warning: you can't use this to copy disks.", },
|
||||||
"readadfs", mainReadADFS,
|
{ "writetestpattern", mainWriteTestPattern, "Writes a machine-generated test pattern to a disk.", },
|
||||||
"Reads Acorn ADFS disks.",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"readaeslanier", mainReadAESLanier,
|
|
||||||
"Reads AES Lanier disks.",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"readamiga", mainReadAmiga,
|
|
||||||
"Reads Commodore Amiga disks.",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"readampro", mainReadAmpro,
|
|
||||||
"Reads Ampro disks.",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"readapple2", mainReadApple2,
|
|
||||||
"Reads Apple II disks.",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"readbrother", mainReadBrother,
|
|
||||||
"Reads 120kB and 240kB Brother word processor disks.",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"readc64", mainReadC64,
|
|
||||||
"Reads Commodore 64 disks.",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"readdfs", mainReadDFS,
|
|
||||||
"Reads Acorn DFS disks.",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"readf85", mainReadF85,
|
|
||||||
"Reads Durango F85 disks.",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"readfb100", mainReadFB100,
|
|
||||||
"Reads FB100 disks.",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"readibm", mainReadIBM,
|
|
||||||
"Reads the ubiquitous IBM format disks.",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"readmac", mainReadMac,
|
|
||||||
"Reads Apple Macintosh disks.",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"readvictor9k", mainReadVictor9K,
|
|
||||||
"Reads Victor 9000 disks.",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"readzilogmcz", mainReadZilogMCZ,
|
|
||||||
"Reads Zilog MCZ disks.",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"rpm", mainRpm,
|
|
||||||
"Measures the disk rotational speed.",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"seek", mainSeek,
|
|
||||||
"Moves the disk head.",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"testbulktransport", mainTestBulkTransport,
|
|
||||||
"Measures your USB bandwidth.",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"upgradefluxfile", mainUpgradeFluxFile,
|
|
||||||
"Upgrades a flux file from a previous version of this software.",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"writebrother", mainWriteBrother,
|
|
||||||
"Writes 120kB and 240kB Brother word processor disks.",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"writeflux", mainWriteFlux,
|
|
||||||
"Writes a raw flux file. Warning: you can't use this to copy disks.",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"writetestpattern", mainWriteTestPattern,
|
|
||||||
"Writes a machine-generated test pattern to a disk.",
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static std::vector<Command> readables =
|
||||||
|
{
|
||||||
|
{ "adfs", mainReadADFS, "Reads Acorn ADFS disks.", },
|
||||||
|
{ "aeslanier", mainReadAESLanier, "Reads AES Lanier disks.", },
|
||||||
|
{ "amiga", mainReadAmiga, "Reads Commodore Amiga disks.", },
|
||||||
|
{ "ampro", mainReadAmpro, "Reads Ampro disks.", },
|
||||||
|
{ "apple2", mainReadApple2, "Reads Apple II disks.", },
|
||||||
|
{ "brother", mainReadBrother, "Reads 120kB and 240kB Brother word processor disks.", },
|
||||||
|
{ "c64", mainReadC64, "Reads Commodore 64 disks.", },
|
||||||
|
{ "dfs", mainReadDFS, "Reads Acorn DFS disks.", },
|
||||||
|
{ "f85", mainReadF85, "Reads Durango F85 disks.", },
|
||||||
|
{ "fb100", mainReadFB100, "Reads FB100 disks.", },
|
||||||
|
{ "ibm", mainReadIBM, "Reads the ubiquitous IBM format disks.", },
|
||||||
|
{ "mac", mainReadMac, "Reads Apple Macintosh disks.", },
|
||||||
|
{ "victor9k", mainReadVictor9K, "Reads Victor 9000 disks.", },
|
||||||
|
{ "zilogmcz", mainReadZilogMCZ, "Reads Zilog MCZ disks.", },
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::vector<Command> writeables =
|
||||||
|
{
|
||||||
|
{ "brother", mainWriteBrother, "Writes 120kB and 240kB Brother word processor disks.", },
|
||||||
|
};
|
||||||
|
|
||||||
|
static void readWriteHelp(std::vector<Command>& subcommands, const std::string& command)
|
||||||
|
{
|
||||||
|
std::cout << "fluxengine: syntax: fluxengine " << command << " <format> [<flags>...]\n"
|
||||||
|
"These formats are supported:\n";
|
||||||
|
|
||||||
|
for (Command& c : subcommands)
|
||||||
|
std::cout << " " << c.name << ": " << c.help << "\n";
|
||||||
|
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int mainReadWrite(std::vector<Command>& subcommands, const std::string& command,
|
||||||
|
int argc, const char* argv[])
|
||||||
|
{
|
||||||
|
if (argc == 1)
|
||||||
|
readWriteHelp(subcommands, command);
|
||||||
|
|
||||||
|
std::string format = argv[1];
|
||||||
|
if (format == "help")
|
||||||
|
readWriteHelp(subcommands, command);
|
||||||
|
|
||||||
|
for (Command& c : subcommands)
|
||||||
|
{
|
||||||
|
if (format == c.name)
|
||||||
|
return c.main(argc-1, argv+1);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cerr << "fluxengine: unrecognised format (try help)\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int mainRead(int argc, const char* argv[])
|
||||||
|
{ return mainReadWrite(readables, "read", argc, argv); }
|
||||||
|
|
||||||
|
static int mainWrite(int argc, const char* argv[])
|
||||||
|
{ return mainReadWrite(writeables, "write", argc, argv); }
|
||||||
|
|
||||||
static void help()
|
static void help()
|
||||||
{
|
{
|
||||||
std::cout << "fluxengine: syntax: fluxengine <command> [<flags>...]\n"
|
std::cout << "fluxengine: syntax: fluxengine <command> [<flags>...]\n"
|
||||||
|
|||||||
Reference in New Issue
Block a user