#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include "bless.h"
#include "enums.h"
#include "structs.h"
#define xstr(s) str(s)
#define str(s) #s
const char *modeList[] = { "Global Options", "Info Mode", "Device Mode", "Folder Mode" };
void usage(struct clopt commandlineopts[]) {
int j;
size_t oldMode;
fprintf(stderr, "Usage: " xstr(PROGRAM) " [options]\n");
for(oldMode = 0; oldMode < (sizeof(modeList)/sizeof(const char *)); oldMode++) {
fprintf(stderr, "%s:\n", modeList[oldMode]);
for(j=0; j < klast; j++) {
if(!(commandlineopts[j].modes & (1 << oldMode)) || (commandlineopts[j].modes & mHidden)) {
continue;
}
if(commandlineopts[j].takesarg == aRequired) {
fprintf(stderr, " -%-9s arg ", commandlineopts[j].flag);
} else if(commandlineopts[j].takesarg == aOptional) {
fprintf(stderr, " -%-9s[arg]", commandlineopts[j].flag);
} else {
fprintf(stderr, " -%-12s ", commandlineopts[j].flag);
}
fprintf(stderr, "\t%s\n", commandlineopts[j].description);
}
fprintf(stderr, "\n");
}
exit(1);
}
void usage_short() {
fprintf(stderr, "Usage: " xstr(PROGRAM) " [options]\n");
fputs(
"bless -help\n"
"\n"
"bless -folder directory [-folder9 directory] [-mount directory]\n"
"\t[-bootinfo file] [-bootBlocks | -bootBlockFile file] [-save9]\n"
"\t[-saveX] [-use9] [-system file] [-systemfile file]\n"
"\t[-label name | -labelfile file] [-openfolder directory] [-setBoot]\n"
"\t[-quiet | -verbose]\n"
"\n"
"bless -device device [-format [fstype] [-fsargs args]\n"
"\t[-label name | -labelfile file]] [-bootBlockFile file]\n"
"\t[-mount directory] [-wrapper file] [-system file] [-startupfile file]\n"
"\t[-setBoot] [-quiet | -verbose]\n"
"\n"
"bless -info [directory] [-bootBlocks] [-getBoot] [-plist]\n"
"\t[-quiet | -verbose] [-version]\n"
,
stderr);
exit(1);
}