cli: Add new write-protect CLI
Add a new write-protect CLI that is based on the classic-CLI feature
in flashrom/master. The syntax is slighty different: With the new
CLI wrapper, we can either call it as `flashprog write-protect` or
`flashprog wp`. To keep the CLI code clean, we allow only one write-
protection operation per call.
For instance, the write-protection status can then be queried like
this:
$ flashprog wp status -p ch341a_spi
Change-Id: I32818b58c9db939719913fc63063c41a27876554
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.sourcearcade.org/c/flashprog/+/72991
diff --git a/include/cli.h b/include/cli.h
index 69b0146..1fbdef6 100644
--- a/include/cli.h
+++ b/include/cli.h
@@ -15,6 +15,8 @@
#ifndef FLASHPROG_CLI_H
#define FLASHPROG_CLI_H
+#include <stdbool.h>
+
#include "libflashprog.h"
enum {
@@ -35,6 +37,12 @@
OPTION_CONFIG_GET,
OPTION_CONFIG_SET,
OPTION_CONFIG_VOLATILE,
+ OPTION_WP_STATUS,
+ OPTION_WP_SET_RANGE,
+ OPTION_WP_SET_REGION,
+ OPTION_WP_ENABLE,
+ OPTION_WP_DISABLE,
+ OPTION_WP_LIST,
};
struct log_args {
@@ -67,6 +75,7 @@
int flashprog_classic_main(int argc, char *argv[]);
int flashprog_config_main(int argc, char *argv[]);
+int flashprog_wp_main(int argc, char *argv[]);
extern enum flashprog_log_level verbose_screen;
extern enum flashprog_log_level verbose_logfile;
@@ -81,6 +90,6 @@
};
int getopt_command(int argc, char *const argv[], const struct opt_command *);
-void print_generic_options(void);
+void print_generic_options(bool layout_options);
#endif