merge --custom and --image

This commit is contained in:
Guaxinim5573 2021-04-14 17:25:11 -03:00
parent 119504feb4
commit e4acabada7

View file

@ -81,25 +81,20 @@ int main(int argc, char *argv[]) {
int opt = 0; int opt = 0;
static struct option long_options[] = { static struct option long_options[] = {
{ "ascii", no_argument, NULL, 'a' }, { "ascii", no_argument, NULL, 'a' },
{ "custom", required_argument, NULL, 'c' },
{ "config", required_argument, NULL, 0}, { "config", required_argument, NULL, 0},
{ "distro", required_argument, NULL, 'd' }, { "distro", required_argument, NULL, 'd' },
{ "help", no_argument, NULL, 'h' }, { "help", no_argument, NULL, 'h' },
{ "image", no_argument, NULL, 'i' }, { "image", optional_argument, NULL, 'i' },
{ "list", no_argument, NULL, 'l' }, { "list", no_argument, NULL, 'l' },
{ NULL, 0, NULL, 0 } { NULL, 0, NULL, 0 }
}; };
get_info(); get_info();
parse_config(); parse_config();
while ((opt = getopt_long(argc, argv, "ad:hilc:", long_options, NULL)) != -1) { while ((opt = getopt_long(argc, argv, "ad:hi::l", long_options, NULL)) != -1) {
switch (opt) { switch (opt) {
case 'a': case 'a':
ascii_image_flag = 0; ascii_image_flag = 0;
break; break;
case 'c':
ascii_image_flag = 1;
sprintf(image_name, "%s", optarg);
break;
case 'd': case 'd':
if (optarg) sprintf(version_name, "%s", optarg); if (optarg) sprintf(version_name, "%s", optarg);
break; break;
@ -108,6 +103,10 @@ int main(int argc, char *argv[]) {
return 0; return 0;
case 'i': case 'i':
ascii_image_flag = 1; ascii_image_flag = 1;
char *image_dir = NULL;
if(!optarg && argv[optind] != NULL && argv[optind][0] != '-') image_dir = argv[optind++];
else image_dir = optarg;
if(image_dir != NULL) sprintf(image_name, "%s", image_dir);
break; break;
case 'l': case 'l':
list(argv[0]); list(argv[0]);