add C-style comment support
This commit is contained in:
parent
f083dcd3d8
commit
69be8312f8
20
Makefile
20
Makefile
@ -1,21 +1,30 @@
|
||||
NAME=multini
|
||||
VERSION=0.2.3
|
||||
NAME = $(shell basename $(shell readlink -e .))
|
||||
VERSION = dev_$(shell date +%F_%T)
|
||||
GOCMD = go
|
||||
LDFLAGS := "$(LDFLAGS) -X 'main.Version=$(VERSION)'"
|
||||
GOBUILD = $(GOCMD) build -ldflags=$(LDFLAGS)
|
||||
SRCMAIN=.
|
||||
SRCMAIN = ./cmd/$(NAME)
|
||||
SRCDOC = ./doc
|
||||
SRCTEST = ./test
|
||||
BINDIR = bin
|
||||
BIN = $(BINDIR)/$(NAME)
|
||||
README=README
|
||||
README = $(SRCDOC)/README
|
||||
LICENSE = LICENSE
|
||||
TEST=./run_test.sh
|
||||
TEST = $(SRCTEST)/run_test.sh
|
||||
PREFIX = /usr
|
||||
|
||||
.PHONY: all prep doc build check-build freebsd-386 darwin-386 linux-386 windows-386 freebsd-amd64 darwin-amd64 linux-amd64 windows-amd64 compile install check-install uninstall clean test
|
||||
|
||||
all: build
|
||||
|
||||
prep: clean
|
||||
go mod init; go mod tidy
|
||||
mkdir $(BINDIR)
|
||||
|
||||
doc: check-build
|
||||
test -d $(SRCDOC) || mkdir $(SRCDOC)
|
||||
$(BIN) --help > $(README)
|
||||
|
||||
build: prep
|
||||
$(GOBUILD) -o $(BIN) $(SRCMAIN)
|
||||
|
||||
@ -71,3 +80,4 @@ clean:
|
||||
|
||||
test: check-build
|
||||
$(TEST) $(BIN)
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"multini/output"
|
||||
"multini/types"
|
||||
"multini/internal/output"
|
||||
"multini/internal/types"
|
||||
)
|
||||
|
||||
func chk() int {
|
||||
|
@ -4,8 +4,8 @@ import (
|
||||
"errors"
|
||||
"os"
|
||||
|
||||
"multini/output"
|
||||
"multini/types"
|
||||
"multini/internal/output"
|
||||
"multini/internal/types"
|
||||
|
||||
"github.com/juju/gnuflag"
|
||||
)
|
||||
|
@ -3,8 +3,8 @@ package main
|
||||
import (
|
||||
"os"
|
||||
|
||||
"multini/output"
|
||||
"multini/types"
|
||||
"multini/internal/output"
|
||||
"multini/internal/types"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -7,8 +7,8 @@ import (
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"multini/output"
|
||||
"multini/types"
|
||||
"multini/internal/output"
|
||||
"multini/internal/types"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -26,15 +26,15 @@ var (
|
||||
|
||||
RxBodyPrefix string = `(?P<` + NgPrefix + `>\s+)?`
|
||||
RxSectionName string = `\[(?P<` + NgSection + `>.+)\]`
|
||||
RxKey string = `(?P<` + NgKey + `>(?:[^;#=]+[^\s=;#]|[^;#=]))?`
|
||||
RxKey string = `(?P<` + NgKey + `>(?:[^;#/=]+[^\s=;#/]|[^;#/=]))?`
|
||||
RxKeyPostfix string = `(?P<` + NgKeyPostfix + `>\s+)?`
|
||||
RxValuePrefix string = `(?P<` + NgValuePrefix + `>\s+)?`
|
||||
RxValue string = `(?P<` + NgValue + `>(?:[^;#]+[^\s;#]|[^;#]))?`
|
||||
RxValue string = `(?P<` + NgValue + `>(?:[^;#/]+[^\s;#/]|[^;#/]))?`
|
||||
RxValuePostfix string = `(?P<` + NgValuePostfix + `>\s+)?`
|
||||
RxKeyVal string = RxKey + RxKeyPostfix + `=` + RxValuePrefix + RxValue + RxValuePostfix
|
||||
RxBody string = `(?:` + RxSectionName + `|` + RxKeyVal + `)?`
|
||||
RxBodyPostfix string = `(?P<` + NgPostifx + `>\s+)?`
|
||||
RxCommentPrefix string = `(?P<` + NgCommentPrefix + `>[#;]\s*)`
|
||||
RxCommentPrefix string = `(?P<` + NgCommentPrefix + `>([#;]|//)\s*)`
|
||||
RxCommentText string = `(?P<` + NgComment + `>.+)?`
|
||||
RxComment string = `(?:` + RxCommentPrefix + RxCommentText + `)?`
|
||||
Rx string = RxBodyPrefix + RxBody + RxBodyPostfix + RxComment
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"multini/types"
|
||||
"multini/internal/types"
|
||||
)
|
||||
|
||||
// Source: https://gist.github.com/var23rav/23ae5d0d4d830aff886c3c970b8f6c6b
|
||||
|
@ -10,7 +10,7 @@ DefKey3=NoSpaces!
|
||||
Key2 = 2
|
||||
Key3 = 3
|
||||
|
||||
[MultipleKeySection]
|
||||
[MultipleKeySection] // C style comment
|
||||
Key = 1
|
||||
Key = 2
|
||||
Key = 3
|
||||
|
@ -9,7 +9,7 @@ DefKey3=NoSpaces!
|
||||
Key1 = 1
|
||||
Key2 = 2
|
||||
|
||||
[MultipleKeySection]
|
||||
[MultipleKeySection] // C style comment
|
||||
Key = 1
|
||||
Key = 2
|
||||
Key = 3
|
||||
|
@ -9,7 +9,7 @@ DefKey3=NoSpaces!
|
||||
Key1 = 1
|
||||
Key2 = 2
|
||||
|
||||
[MultipleKeySection]
|
||||
[MultipleKeySection] // C style comment
|
||||
Key = 1
|
||||
Key = 2
|
||||
Key = 3
|
||||
|
@ -8,7 +8,7 @@ DefKey3=NoSpaces!
|
||||
[SimpleSection] # Comment For Section
|
||||
Key2 = 2
|
||||
|
||||
[MultipleKeySection]
|
||||
[MultipleKeySection] // C style comment
|
||||
Key = 1
|
||||
Key = 2
|
||||
Key = 3
|
||||
|
@ -9,7 +9,7 @@ DefKey3=NoSpaces!
|
||||
Key1 = 1
|
||||
Key2 = 2
|
||||
|
||||
[MultipleKeySection]
|
||||
[MultipleKeySection] // C style comment
|
||||
|
||||
[SectionWithIndent]
|
||||
Key=Value
|
||||
|
@ -9,7 +9,7 @@ DefKey3=NoSpaces!
|
||||
Key1 = 1
|
||||
Key2 = 2
|
||||
|
||||
[MultipleKeySection]
|
||||
[MultipleKeySection] // C style comment
|
||||
Key = 1
|
||||
Key = 3
|
||||
|
||||
|
@ -9,7 +9,7 @@ DefKey3=NoSpaces!
|
||||
Key1 = 1
|
||||
Key2 = 2
|
||||
|
||||
[MultipleKeySection]
|
||||
[MultipleKeySection] // C style comment
|
||||
Key = 1
|
||||
Key = 2
|
||||
Key = 3
|
||||
|
@ -9,7 +9,7 @@ DefKey3=NoSpaces!
|
||||
Key1 = 1
|
||||
Key2 = 2
|
||||
|
||||
[MultipleKeySection]
|
||||
[MultipleKeySection] // C style comment
|
||||
Key = onlyone
|
||||
|
||||
[SectionWithIndent]
|
||||
|
@ -9,7 +9,7 @@ DefKey3=NoSpaces!
|
||||
Key1 = 1
|
||||
Key2 = 2
|
||||
|
||||
[MultipleKeySection]
|
||||
[MultipleKeySection] // C style comment
|
||||
Key = 1
|
||||
Key = 2
|
||||
Key = 3
|
||||
|
@ -9,7 +9,7 @@ DefKey3=NoSpaces!
|
||||
Key1 = 1
|
||||
Key2 = 2
|
||||
|
||||
[MultipleKeySection]
|
||||
[MultipleKeySection] // C style comment
|
||||
Key = 1
|
||||
Key = 2
|
||||
Key = 3
|
||||
|
@ -9,7 +9,7 @@ DefKey3=NoSpaces!
|
||||
Key1 = 1
|
||||
Key2 = 2
|
||||
|
||||
[MultipleKeySection]
|
||||
[MultipleKeySection] // C style comment
|
||||
Key = 1
|
||||
Key = 2
|
||||
Key = 3
|
||||
|
@ -9,7 +9,7 @@ DefKey3=NoSpaces!
|
||||
Key1 = 1
|
||||
Key2 = 2
|
||||
|
||||
[MultipleKeySection]
|
||||
[MultipleKeySection] // C style comment
|
||||
Key = 1
|
||||
Key = 2
|
||||
Key = 3
|
||||
|
@ -9,7 +9,7 @@ DefKey3=NoSpaces!
|
||||
Key1 = 1
|
||||
Key2 = 2
|
||||
|
||||
[MultipleKeySection]
|
||||
[MultipleKeySection] // C style comment
|
||||
Key = 1
|
||||
Key = 2
|
||||
Key = 3
|
||||
|
@ -9,7 +9,7 @@ DefKey3=NoSpaces!
|
||||
Key1 = 1
|
||||
Key2 = 2
|
||||
|
||||
[MultipleKeySection]
|
||||
[MultipleKeySection] // C style comment
|
||||
Key = 1
|
||||
Key = 2
|
||||
Key = 3
|
||||
|
@ -9,7 +9,7 @@ DefKey3=NoSpaces!
|
||||
Key1 = 1
|
||||
Key2 = 2
|
||||
|
||||
[MultipleKeySection]
|
||||
[MultipleKeySection] // C style comment
|
||||
Key = 1
|
||||
Key = 2
|
||||
Key = 3
|
||||
|
@ -9,7 +9,7 @@ DefKey3=NoSpaces!
|
||||
Key1 = 1
|
||||
Key2 = 2
|
||||
|
||||
[MultipleKeySection]
|
||||
[MultipleKeySection] // C style comment
|
||||
Key = 1
|
||||
Key = 2
|
||||
Key = 3
|
||||
|
@ -9,7 +9,7 @@ DefKey3=NoSpaces!
|
||||
Key1 = 1
|
||||
Key2 = 2
|
||||
|
||||
[MultipleKeySection]
|
||||
[MultipleKeySection] // C style comment
|
||||
Key = 1
|
||||
Key = 2
|
||||
Key = 3
|
||||
|
@ -9,7 +9,7 @@ DefKey3=NoSpaces!
|
||||
Key1 = 1
|
||||
Key2 = 2
|
||||
|
||||
[MultipleKeySection]
|
||||
[MultipleKeySection] // C style comment
|
||||
Key = 1
|
||||
Key = 2
|
||||
Key = 3
|
||||
|
@ -9,7 +9,7 @@ DefKey3=NoSpaces!
|
||||
Key1 = 1
|
||||
Key2 = 2
|
||||
|
||||
[MultipleKeySection]
|
||||
[MultipleKeySection] // C style comment
|
||||
Key = 1
|
||||
Key = 2
|
||||
Key = 3
|
||||
|
@ -9,7 +9,7 @@ DefKey3=NoSpaces!
|
||||
Key1 = 1
|
||||
Key2 = 2
|
||||
|
||||
[MultipleKeySection]
|
||||
[MultipleKeySection] // C style comment
|
||||
Key = 1
|
||||
Key = 2
|
||||
Key = 3
|
||||
|
@ -1,10 +1,11 @@
|
||||
#!/bin/bash
|
||||
|
||||
DEF='\e[0m'; BLD='\e[1m'; RED='\e[31m'; GRN='\e[32m'; WHT='\e[97m'
|
||||
|
||||
ScriptFullname=$(readlink -e "$0")
|
||||
ScriptName=$(echo "$ScriptFullname" | awk -F '/' '{print $NF;}')
|
||||
ScriptDir=$(dirname "$ScriptFullname")
|
||||
TestDir="$ScriptDir/tests"
|
||||
TestDir="$ScriptDir/data"
|
||||
Multini=$(readlink -e "$1")
|
||||
|
||||
if [[ -z "$Multini" ]]; then
|
||||
|
Loading…
x
Reference in New Issue
Block a user