First pass at displaying Menu files
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"io"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var hashComment = []byte("#")
|
||||
@@ -60,6 +61,22 @@ func (s *Scanner) ConsumeString() (string, error) {
|
||||
return "", err
|
||||
}
|
||||
|
||||
// It's common for properties to be specified as "foo : bar". Parse them out.
|
||||
func ConsumeProperty(s string) (string, string) {
|
||||
if !IsProperty(s) {
|
||||
return "", ""
|
||||
}
|
||||
|
||||
parts := strings.SplitN(s, ":", 2)
|
||||
return strings.TrimSpace(parts[0]), strings.TrimSpace(parts[1])
|
||||
}
|
||||
|
||||
// Peek ahead in the input stream to see if the next line might be a property
|
||||
// (contain a colon character).
|
||||
func IsProperty(s string) bool {
|
||||
return strings.Contains(s, ":")
|
||||
}
|
||||
|
||||
func (s *Scanner) ConsumeInt() (int, error) {
|
||||
str, err := s.ConsumeString()
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user