bat-modules: Add --modules-file option

This commit is contained in:
Ethan P 2020-07-06 18:15:01 -07:00
parent df5b237273
commit fa58888298
No known key found for this signature in database
GPG Key ID: 6963FD04F6CF35EA
2 changed files with 14 additions and 7 deletions

View File

@ -142,7 +142,7 @@ dsl_parse_line() {
# Escape the parsed value.
sub(/"/, "\\\"", buffer)
sub(/\$/, "\\\$", buffer)
sub(/\$/, "\\$", buffer)
# Print the parsed value.
print sprintf("line_fields[%s]=\"%s\"", n, buffer)

View File

@ -35,10 +35,11 @@ ACTION="help"
while shiftopt; do
case "$OPT" in
--help) ACTION="help" ;;
--update) ACTION="update" ;;
--clear) ACTION="clear" ;;
--setup) ACTION="setup" ;;
--help) ACTION="help" ;;
--update) ACTION="update" ;;
--clear) ACTION="clear" ;;
--setup) ACTION="setup" ;;
--modules-file) ACTION="show_file" ;;
# ???
-*) {
@ -161,6 +162,10 @@ parse_source_name() {
# Actions:
# -----------------------------------------------------------------------------
action:show_file() {
printf "%s\n" "$MODULES_FILE"
}
action:setup() {
if ! [[ -f "$MODULES_FILE" ]]; then
cat > "$MODULES_FILE" <<-EOF
@ -180,8 +185,10 @@ EOF
action:help() {
{
printc "%{YELLOW}%s help:%{CLEAR}\n" "$PROGRAM"
printc " --clear -- Clear the cached themes and syntaxes.\n"
printc " --update -- Update themes and syntaxes.\n"
printc " --clear -- Clear the cached themes and syntaxes.\n"
printc " --update -- Update themes and syntaxes.\n"
printc " --setup -- Edit the bat-modules modules.txt file.\n"
printc " --modules-file -- Show the bat-modules modules.txt file.\n"
} 1>&2
}