Print error when no bitfile is specified
This commit is contained in:
parent
1f02fce1c9
commit
2b2806b0b4
15
src/main.cpp
15
src/main.cpp
|
|
@ -49,6 +49,7 @@ struct arguments {
|
||||||
bool list_fpga;
|
bool list_fpga;
|
||||||
bool write_flash;
|
bool write_flash;
|
||||||
bool write_sram;
|
bool write_sram;
|
||||||
|
bool is_list_command;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define LIST_CABLE 1
|
#define LIST_CABLE 1
|
||||||
|
|
@ -86,11 +87,11 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
/* command line args. */
|
/* command line args. */
|
||||||
struct arguments args = {false, false, 0, "", "-", "-", "-",
|
struct arguments args = {false, false, 0, "", "-", "-", "-",
|
||||||
false, false, false, false, true};
|
false, false, false, false, true, false};
|
||||||
/* parse arguments */
|
/* parse arguments */
|
||||||
argp_parse(&argp, argc, argv, 0, 0, &args);
|
argp_parse(&argp, argc, argv, 0, 0, &args);
|
||||||
|
|
||||||
if (args.list_boards == true || args.list_cables == true || args.list_fpga) {
|
if (args.is_list_command) {
|
||||||
displaySupported(args);
|
displaySupported(args);
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
@ -213,15 +214,24 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state)
|
||||||
arguments->bit_file = arg;
|
arguments->bit_file = arg;
|
||||||
break;
|
break;
|
||||||
case ARGP_KEY_END:
|
case ARGP_KEY_END:
|
||||||
|
if (arguments->bit_file.empty() &&
|
||||||
|
!arguments->is_list_command &&
|
||||||
|
!arguments->reset) {
|
||||||
|
cout << "Error: bitfile not specified" << endl;
|
||||||
|
argp_usage(state);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case LIST_CABLE:
|
case LIST_CABLE:
|
||||||
arguments->list_cables = true;
|
arguments->list_cables = true;
|
||||||
|
arguments->is_list_command = true;
|
||||||
break;
|
break;
|
||||||
case LIST_BOARD:
|
case LIST_BOARD:
|
||||||
arguments->list_boards = true;
|
arguments->list_boards = true;
|
||||||
|
arguments->is_list_command = true;
|
||||||
break;
|
break;
|
||||||
case LIST_FPGA:
|
case LIST_FPGA:
|
||||||
arguments->list_fpga = true;
|
arguments->list_fpga = true;
|
||||||
|
arguments->is_list_command = true;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return ARGP_ERR_UNKNOWN;
|
return ARGP_ERR_UNKNOWN;
|
||||||
|
|
@ -275,3 +285,4 @@ void displaySupported(const struct arguments &args)
|
||||||
cout << endl;
|
cout << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue