Merge pull request #63 from zimmski/optional-description
Empty descriptions should not leave any output
diff --git a/help_test.go b/help_test.go
index e10e44c..deeb6a5 100644
--- a/help_test.go
+++ b/help_test.go
@@ -41,9 +41,10 @@
}
type helpOptions struct {
- Verbose []bool `short:"v" long:"verbose" description:"Show verbose debug information" ini-name:"verbose"`
- Call func(string) `short:"c" description:"Call phone number" ini-name:"call"`
- PtrSlice []*string `long:"ptrslice" description:"A slice of pointers to string"`
+ Verbose []bool `short:"v" long:"verbose" description:"Show verbose debug information" ini-name:"verbose"`
+ Call func(string) `short:"c" description:"Call phone number" ini-name:"call"`
+ PtrSlice []*string `long:"ptrslice" description:"A slice of pointers to string"`
+ EmptyDescription bool `long:"empty-description"`
OnlyIni string `ini-name:"only-ini" description:"Option only available in ini"`
@@ -80,16 +81,17 @@
TestHelp [OPTIONS] <command>
Application Options:
- -v, --verbose Show verbose debug information
- -c= Call phone number
- --ptrslice= A slice of pointers to string
+ -v, --verbose Show verbose debug information
+ -c= Call phone number
+ --ptrslice= A slice of pointers to string
+ --empty-description
Other Options:
- -s= A slice of strings
- --intmap= A map from string to int
+ -s= A slice of strings
+ --intmap= A map from string to int
Help Options:
- -h, --help Show this help message
+ -h, --help Show this help message
Available commands:
command A command
@@ -143,6 +145,8 @@
\fB--ptrslice\fP
A slice of pointers to string
.TP
+\fB--empty-description\fP
+.TP
\fB-s\fP
A slice of strings
.TP
diff --git a/ini_private.go b/ini_private.go
index 71970de..0371b87 100644
--- a/ini_private.go
+++ b/ini_private.go
@@ -90,7 +90,7 @@
sectionwritten = true
}
- if comments {
+ if comments && len(option.Description) != 0 {
fmt.Fprintf(writer, "; %s\n", option.Description)
}
diff --git a/ini_test.go b/ini_test.go
index 8bb7acd..b3b8a8b 100644
--- a/ini_test.go
+++ b/ini_test.go
@@ -32,6 +32,8 @@
; A slice of pointers to string
; PtrSlice =
+EmptyDescription = false
+
; Option only available in ini
only-ini =
diff --git a/man.go b/man.go
index 89fdc7c..cfe8037 100644
--- a/man.go
+++ b/man.go
@@ -54,8 +54,10 @@
}
fmt.Fprintln(wr, "\\fP")
- formatForMan(wr, opt.Description)
- fmt.Fprintln(wr, "")
+ if len(opt.Description) != 0 {
+ formatForMan(wr, opt.Description)
+ fmt.Fprintln(wr, "")
+ }
}
})
}