mirror of
https://github.com/nitanmarcel/isodrive.git
synced 2026-03-13 04:17:24 +00:00
Add simple argument parser
This commit is contained in:
40
src/main.cpp
40
src/main.cpp
@@ -1,11 +1,45 @@
|
||||
#include "configfsisomanager.h"
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int main(int argc, char* argv[]){
|
||||
char *iso_target = argv[1];
|
||||
char *cdrom = (char*)"0";
|
||||
char *ro = (char*)"1";
|
||||
char *iso_target = argv[1];
|
||||
char *cdrom = (char*)"0";
|
||||
char *ro = (char*)"1";
|
||||
|
||||
for (int i = 1; i < argc; i++)
|
||||
{
|
||||
if (strcmp(argv[i], "-rw") == 0)
|
||||
{
|
||||
ro = (char*)"0";
|
||||
}
|
||||
else if (strcmp(argv[i], "-cdrom") == 0)
|
||||
{
|
||||
cdrom = (char*)"1";
|
||||
}
|
||||
else
|
||||
{
|
||||
iso_target = argv[i];
|
||||
}
|
||||
}
|
||||
|
||||
if (argc == 1)
|
||||
{
|
||||
printf("Usage:\n");
|
||||
printf("cdrom [FILE]... [OPTION]...\n");
|
||||
printf("Mounts the given FILE as a bootable device using configfs.\n");
|
||||
printf("Run without any arguments to unmount any mounted files and display this help message.\n\n");
|
||||
|
||||
printf("Optional arguments:\n");
|
||||
printf("-rw\t Mounts the file in read write mode.\n");
|
||||
printf("-cdrom\t Mounts the file as a cdrom.\n\n");
|
||||
printf("UMOUNT:\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("MOUNT:\n");
|
||||
}
|
||||
|
||||
if (!supported())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user