Add -w flag support to grep

Change-Id: I4fc68de1c30c91f3356c42b18c3f74d282eec441
diff --git a/cmd/jiri/grep.go b/cmd/jiri/grep.go
index 7829639..a22830f 100644
--- a/cmd/jiri/grep.go
+++ b/cmd/jiri/grep.go
@@ -32,6 +32,7 @@
 	e string
 	l bool
 	L bool
+	w bool
 }
 
 func init() {
@@ -41,6 +42,7 @@
 	flags.BoolVar(&grepFlags.h, "H", true, "Does nothing. Just makes this git grep compatible")
 	flags.BoolVar(&grepFlags.i, "i", false, "Ignore case differences between the patterns and the files")
 	flags.BoolVar(&grepFlags.l, "l", false, "Instead of showing every matched line, show only the names of files that contain matches")
+	flags.BoolVar(&grepFlags.w, "w", false, "Match the pattern only at word boundary")
 	flags.BoolVar(&grepFlags.l, "name-only", false, "same as -l")
 	flags.BoolVar(&grepFlags.l, "files-with-matches", false, "same as -l")
 	flags.BoolVar(&grepFlags.L, "L", false, "Instead of showing every matched line, show only the names of files that do not contain matches")
@@ -64,6 +66,9 @@
 	if grepFlags.L {
 		args = append(args, "-L")
 	}
+	if grepFlags.w {
+		args = append(args, "-w")
+	}
 	return args
 }
 
diff --git a/cmd/jiri/grep_test.go b/cmd/jiri/grep_test.go
index 9571f76..f02ec41 100644
--- a/cmd/jiri/grep_test.go
+++ b/cmd/jiri/grep_test.go
@@ -23,6 +23,7 @@
 	grepFlags.i = false
 	grepFlags.l = false
 	grepFlags.L = false
+	grepFlags.w = false
 }
 
 func makeProjects(t *testing.T, fake *jiritest.FakeJiriRoot) []*project.Project {
@@ -131,6 +132,19 @@
 	})
 }
 
+func TestWFlagGrep(t *testing.T) {
+	fake, cleanup := jiritest.NewFakeJiriRoot(t)
+	defer cleanup()
+
+	setup(t, fake)
+	setDefaultGrepFlags()
+	grepFlags.w = true
+	grepFlags.i = true
+	expectGrep(t, fake, []string{"i"}, []string{
+		"r.a/file.txt:Shall I compare thee to a summer's day?",
+	})
+}
+
 func TestEFlagGrep(t *testing.T) {
 	fake, cleanup := jiritest.NewFakeJiriRoot(t)
 	defer cleanup()