Add noconfirm flag

This commit is contained in:
Imbus 2026-02-07 17:24:31 +01:00
parent 13e27bbcc1
commit c67c68615a

View file

@ -57,11 +57,12 @@ const char help[] =
" writeimg [-v] -d <device> <file.img>\n"
"\n"
"Args:\n"
" <file.img> Binary image file\n"
" -v Verify only\n"
" -d device Target block device\n"
" -h, --help Print this help message\n"
" -V, --version Print version\n"
" <file.img> Binary image file\n"
" -v Verify only\n"
" -d device Target block device\n"
" -h, --help Print this help message\n"
" -n, --noconfirm Do not ask for premission\n"
" -V, --version Print version\n"
"\0";
// clang-format on
@ -209,12 +210,14 @@ int main(int argc, char *argv[]) {
signal(SIGHUP, int_handler);
signal(SIGTERM, int_handler);
int ask_permission = 1;
int c = {0};
while ((c = getopt_long(argc, argv, "vd:hV", longopts, 0)) != -1) {
while ((c = getopt_long(argc, argv, "vd:hnV", longopts, 0)) != -1) {
switch (c) {
case 'v': ++wjob.verify_only; continue;
case 'd': wjob.dev_name = optarg; continue;
case 'h': break;
case 'n': --ask_permission; continue;
case 'V': exit(EXIT_SUCCESS);
}
printf("%s\n", help);