Merge pull request #2 from alecthomas/master

Add ability to disable interspersed option support.
diff --git a/flag.go b/flag.go
index 0154001..743e011 100644
--- a/flag.go
+++ b/flag.go
@@ -271,6 +271,7 @@
 	exitOnError   bool     // does the program exit if there's an error?
 	errorHandling ErrorHandling
 	output        io.Writer // nil means stderr; use out() accessor
+	interspersed  bool      // allow interspersed option/non-option args
 }
 
 // A Flag represents the state of a flag.
@@ -927,6 +928,11 @@
 		s := args[0]
 		args = args[1:]
 		if len(s) == 0 || s[0] != '-' || len(s) == 1 {
+			if !f.interspersed {
+				f.args = append(f.args, s)
+				f.args = append(f.args, args...)
+				return nil
+			}
 			f.args = append(f.args, s)
 			continue
 		}
@@ -1030,6 +1036,11 @@
 	commandLine.Parse(os.Args[1:])
 }
 
+// Whether to support interspersed option/non-option arguments.
+func SetInterspersed(interspersed bool) {
+	commandLine.SetInterspersed(interspersed)
+}
+
 // Parsed returns true if the command-line flags have been parsed.
 func Parsed() bool {
 	return commandLine.Parsed()
@@ -1044,10 +1055,16 @@
 	f := &FlagSet{
 		name:          name,
 		errorHandling: errorHandling,
+		interspersed:  true,
 	}
 	return f
 }
 
+// Whether to support interspersed option/non-option arguments.
+func (f *FlagSet) SetInterspersed(interspersed bool) {
+	f.interspersed = interspersed
+}
+
 // Init sets the name and error handling property for a flag set.
 // By default, the zero FlagSet uses an empty name and the
 // ContinueOnError error handling policy.
diff --git a/flag_test.go b/flag_test.go
index 9caa8c4..42d5483 100644
--- a/flag_test.go
+++ b/flag_test.go
@@ -335,3 +335,18 @@
 		t.Fatal("help was called; should not have been for defined help flag")
 	}
 }
+
+func TestNoInterspersed(t *testing.T) {
+	f := NewFlagSet("test", ContinueOnError)
+	f.SetInterspersed(false)
+	f.Bool("true", true, "always true")
+	f.Bool("false", false, "always false")
+	err := f.Parse([]string{"--true", "break", "--false"})
+	if err != nil {
+		t.Fatal("expected no error; got ", err)
+	}
+	args := f.Args()
+	if len(args) != 2 || args[0] != "break" || args[1] != "--false" {
+		t.Fatal("expected interspersed options/non-options to fail")
+	}
+}