release: 0.2.2

- stop parsing options when pos args started
- add sections with newline before
This commit is contained in:
GenZmeY 2020-04-29 11:38:02 +03:00
parent 325c6c25d7
commit 0ea49ff1ad
4 changed files with 11 additions and 2 deletions

View File

@ -1,5 +1,5 @@
NAME=multini NAME=multini
VERSION=0.2.1 VERSION=0.2.2
GOCMD=go GOCMD=go
LDFLAGS:="$(LDFLAGS) -X 'main.Version=$(VERSION)'" LDFLAGS:="$(LDFLAGS) -X 'main.Version=$(VERSION)'"
GOBUILD=$(GOCMD) build -ldflags=$(LDFLAGS) GOBUILD=$(GOCMD) build -ldflags=$(LDFLAGS)

View File

@ -100,7 +100,7 @@ func init() {
} }
func parseArgs() error { func parseArgs() error {
gnuflag.Parse(true) gnuflag.Parse(false)
// info // info
switch { switch {

View File

@ -17,4 +17,5 @@ DefKey3=NoSpaces!
[SectionWithIndent] [SectionWithIndent]
Key=Value Key=Value
[SectionWithoutNewLineBefore] [SectionWithoutNewLineBefore]
[NewSection] [NewSection]

View File

@ -89,6 +89,14 @@ func (obj *Ini) GetKeyVal(section, key, value string) error {
func (obj *Ini) AddSection(section string) *Section { func (obj *Ini) AddSection(section string) *Section {
sect, err := obj.FindSection(section) sect, err := obj.FindSection(section)
if err != nil { if err != nil {
sectSize := len(obj.Sections)
if sectSize > 1 {
prevSect := obj.Sections[sectSize-1].(*Section)
lineSize := len(prevSect.Lines)
if lineSize == 0 || lineSize > 0 && prevSect.Lines[lineSize-1].Type() != TEmptyLine {
obj.Sections[sectSize-1].(*Section).Lines = append(obj.Sections[sectSize-1].(*Section).Lines, &EmptyLine{})
}
}
var newSection Section var newSection Section
newSection.Name = section newSection.Name = section
newSection.Prefix = obj.Sections[len(obj.Sections)-1].Indent() newSection.Prefix = obj.Sections[len(obj.Sections)-1].Indent()