use colors

This commit is contained in:
anon 2025-01-23 23:32:45 +01:00
parent 51e95961c7
commit 3a13bd91ce
3 changed files with 26 additions and 10 deletions

View File

@ -14,6 +14,7 @@
[X] recursion
[X] dryrun
[X] use ${VIMDIREDITOR}
[X] NO_COLOR / color
## SYNOPSIS
**vidir** **[***options***]** **[**directory**]**
@ -93,6 +94,11 @@ Editor to use.
`rm` alternative to use.
Set this to an appropriate executable to have move-to-trash behaviour on delete.
**NO_COLOR**
According to the no-color convention,
if this variable is set and is not empty,
no colors will be printed.
## NOTES
The default editor is *Vi*.

View File

@ -6,18 +6,18 @@
static
void verror(const char * fmt, va_list argv) {
fdictatef(stderr, "vimdir: error: ");
fdictatef(stderr, "$rvimdir: error: ");
vafdictatef(stderr, fmt, argv);
fdictate(stderr, "");
fdictate(stderr, "$0");
}
void warning(const char * fmt, ...) {
va_list argv;
va_start(argv, fmt);
fdictatef(stderr, "vimdir: warning: ");
fdictatef(stderr, "$yvimdir: warning: ");
vafdictatef(stderr, fmt, argv);
fdictate(stderr, "");
fdictate(stderr, "$0");
va_end(argv);
}

View File

@ -5,17 +5,27 @@
#include <string.h>
#include <getopt.h>
#include "global.h"
#include "dictate.h"
void usage() {
puts("vimdir <path>");
puts(" -h : print help");
puts(" -n : dry run; do not modify files, just print operations");
puts(" -p : allow for editing permissions");
puts(" -o : allow for editing owner/group");
puts(" -r : recursive");
dictate(
"$B$gvimdir$0 $y[$boptions$y] <$bpath$y>$0\n"
" $B$g-h$0 : print help\n"
" $B$g-n$0 : dry run; do not modify files, just print operations\n"
" $B$g-p$0 : allow for editing permissions\n"
" $B$g-o$0 : allow for editing owner/group\n"
" $B$g-r$0 : recursive"
);
}
void get_env(void) {
no_color:
char * no_color = getenv("NO_COLOR");
if (no_color
&& no_color[0] != '\0') {
dictate_color_enabled(false);
}
set_editor:
editor = getenv("VIMDIREDITOR");
if (editor) { goto set_custom_rm; }