Skip to content

Commit

Permalink
Add --no-color command line option
Browse files Browse the repository at this point in the history
  • Loading branch information
mikesart committed Sep 4, 2024
1 parent ea8a291 commit f96ce07
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 18 deletions.
21 changes: 21 additions & 0 deletions inotify-info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,24 @@ static char thousands_sep = ',';

static std::vector<std::string> ignore_dirs;

const char *RESET = "\x1b[0m";
const char *YELLOW = "\x1b[0;33m";
const char *CYAN = "\x1b[0;36m";
const char *BGRAY = "\x1b[1;30m";
const char *BGREEN = "\x1b[1;32m";
const char *BYELLOW = "\x1b[1;33m";
const char *BCYAN = "\x1b[1;36m";

void set_no_color() {
RESET = "";
YELLOW = "";
CYAN = "";
BGRAY = "";
BGREEN = "";
BYELLOW = "";
BCYAN = "";
}

/*
* filename info
*/
Expand Down Expand Up @@ -1007,6 +1025,7 @@ static void parse_cmdline(int argc, char** argv, std::vector<std::string>& cmdli
{
static struct option long_opts[] = {
{ "verbose", no_argument, 0, 0 },
{ "no-color", no_argument, 0, 0 },
{ "threads", required_argument, 0, 0 },
{ "ignoredir", required_argument, 0, 0 },
{ "version", no_argument, 0, 0 },
Expand All @@ -1032,6 +1051,8 @@ static void parse_cmdline(int argc, char** argv, std::vector<std::string>& cmdli
}
if (!strcasecmp("verbose", long_opts[opt_ind].name))
g_verbose++;
else if (!strcasecmp("no-color", long_opts[opt_ind].name))
set_no_color();
else if (!strcasecmp("threads", long_opts[opt_ind].name))
g_numthreads = atoi(optarg);
else if (!strcasecmp("ignoredir", long_opts[opt_ind].name)) {
Expand Down
18 changes: 0 additions & 18 deletions inotify-info.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,6 @@
* THE SOFTWARE.
*/

#define RESET "\x1b[0m"
#define GRAY "\x1b[0;30m"
#define RED "\x1b[0;31m"
#define GREEN "\x1b[0;32m"
#define YELLOW "\x1b[0;33m"
#define BLUE "\x1b[0;34m"
#define MAGENTA "\x1b[0;35m"
#define CYAN "\x1b[0;36m"
#define WHITE "\x1b[0;37m"
#define BGRAY "\x1b[1;30m"
#define BRED "\x1b[1;31m"
#define BGREEN "\x1b[1;32m"
#define BYELLOW "\x1b[1;33m"
#define BBLUE "\x1b[1;34m"
#define BMAGENTA "\x1b[1;35m"
#define BCYAN "\x1b[1;36m"
#define BWHITE "\x1b[1;37m"

#define TO_STR(x) #x
#define TO_STR_VALUE(x) TO_STR(x)

Expand Down

0 comments on commit f96ce07

Please sign in to comment.