+int main(int argc, const char *argv[])
+{
+ // Parse arguments
+ for( int i = 1; i < argc; i ++ )
+ {
+ const char *arg = argv[i];
+ if( arg[0] != '-' )
+ {
+ int rv = RunCommand(argc-i, argv+i);
+ if( rv == 0 ) {
+ PrintUsage();
+ return 1;
+ }
+ else if( rv < 0 ) {
+ return 0;
+ }
+ else {
+ }
+ i += rv;
+ }
+ else if( arg[1] != '-' )
+ {
+ switch( *++arg )
+ {
+ case 's':
+ if( i+1 >= argc ) {
+ fprintf(stderr, "Option '-s' requires an argument\n");
+ return 1;
+ }
+ RunScript( argv[++i] );
+ break;
+ default:
+ fprintf(stderr, "Unkown option '-%c', try --help\n", *arg);
+ return 1;
+ }
+ }
+ else
+ {
+ if( strcmp(arg, "--help") == 0 ) {
+ PrintUsage();
+ return 0;
+ }
+ else if( strcmp(arg, "--version") == 0 ) {
+ fprintf(stderr, VERSION_STR);
+ return 0;
+ }
+ else {
+ fprintf(stderr, "Unknown option '%s', try --help\n", arg);
+ return 1;
+ }
+ }
+ }
+
+ DiskTool_Cleanup();
+
+ return 0;
+}
+