@@ -25,26 +25,39 @@ func TestNewCmdView(t *testing.T) {
2525 tty : true ,
2626 cli : "123" ,
2727 wants : ViewOptions {
28- Raw : false ,
29- Selector : "123" ,
28+ Raw : false ,
29+ Selector : "123" ,
30+ ListFiles : false ,
3031 },
3132 },
3233 {
3334 name : "nontty no arguments" ,
3435 cli : "123" ,
3536 wants : ViewOptions {
36- Raw : true ,
37- Selector : "123" ,
37+ Raw : true ,
38+ Selector : "123" ,
39+ ListFiles : false ,
3840 },
3941 },
4042 {
4143 name : "filename passed" ,
4244 cli : "-fcool.txt 123" ,
4345 tty : true ,
4446 wants : ViewOptions {
45- Raw : false ,
46- Selector : "123" ,
47- Filename : "cool.txt" ,
47+ Raw : false ,
48+ Selector : "123" ,
49+ Filename : "cool.txt" ,
50+ ListFiles : false ,
51+ },
52+ },
53+ {
54+ name : "files passed" ,
55+ cli : "--files 123" ,
56+ tty : true ,
57+ wants : ViewOptions {
58+ Raw : false ,
59+ Selector : "123" ,
60+ ListFiles : true ,
4861 },
4962 },
5063 }
@@ -92,14 +105,16 @@ func Test_viewRun(t *testing.T) {
92105 {
93106 name : "no such gist" ,
94107 opts : & ViewOptions {
95- Selector : "1234" ,
108+ Selector : "1234" ,
109+ ListFiles : false ,
96110 },
97111 wantErr : true ,
98112 },
99113 {
100114 name : "one file" ,
101115 opts : & ViewOptions {
102- Selector : "1234" ,
116+ Selector : "1234" ,
117+ ListFiles : false ,
103118 },
104119 gist : & shared.Gist {
105120 Files : map [string ]* shared.GistFile {
@@ -114,8 +129,9 @@ func Test_viewRun(t *testing.T) {
114129 {
115130 name : "filename selected" ,
116131 opts : & ViewOptions {
117- Selector : "1234" ,
118- Filename : "cicada.txt" ,
132+ Selector : "1234" ,
133+ Filename : "cicada.txt" ,
134+ ListFiles : false ,
119135 },
120136 gist : & shared.Gist {
121137 Files : map [string ]* shared.GistFile {
@@ -134,9 +150,10 @@ func Test_viewRun(t *testing.T) {
134150 {
135151 name : "filename selected, raw" ,
136152 opts : & ViewOptions {
137- Selector : "1234" ,
138- Filename : "cicada.txt" ,
139- Raw : true ,
153+ Selector : "1234" ,
154+ Filename : "cicada.txt" ,
155+ Raw : true ,
156+ ListFiles : false ,
140157 },
141158 gist : & shared.Gist {
142159 Files : map [string ]* shared.GistFile {
@@ -155,7 +172,8 @@ func Test_viewRun(t *testing.T) {
155172 {
156173 name : "multiple files, no description" ,
157174 opts : & ViewOptions {
158- Selector : "1234" ,
175+ Selector : "1234" ,
176+ ListFiles : false ,
159177 },
160178 gist : & shared.Gist {
161179 Files : map [string ]* shared.GistFile {
@@ -174,7 +192,8 @@ func Test_viewRun(t *testing.T) {
174192 {
175193 name : "multiple files, trailing newlines" ,
176194 opts : & ViewOptions {
177- Selector : "1234" ,
195+ Selector : "1234" ,
196+ ListFiles : false ,
178197 },
179198 gist : & shared.Gist {
180199 Files : map [string ]* shared.GistFile {
@@ -193,7 +212,8 @@ func Test_viewRun(t *testing.T) {
193212 {
194213 name : "multiple files, description" ,
195214 opts : & ViewOptions {
196- Selector : "1234" ,
215+ Selector : "1234" ,
216+ ListFiles : false ,
197217 },
198218 gist : & shared.Gist {
199219 Description : "some files" ,
@@ -213,8 +233,9 @@ func Test_viewRun(t *testing.T) {
213233 {
214234 name : "multiple files, raw" ,
215235 opts : & ViewOptions {
216- Selector : "1234" ,
217- Raw : true ,
236+ Selector : "1234" ,
237+ Raw : true ,
238+ ListFiles : false ,
218239 },
219240 gist : & shared.Gist {
220241 Description : "some files" ,
@@ -231,6 +252,46 @@ func Test_viewRun(t *testing.T) {
231252 },
232253 wantOut : "some files\n \n cicada.txt\n \n bwhiizzzbwhuiiizzzz\n \n foo.md\n \n - foo\n " ,
233254 },
255+ {
256+ name : "one file, list files" ,
257+ opts : & ViewOptions {
258+ Selector : "1234" ,
259+ Raw : false ,
260+ ListFiles : true ,
261+ },
262+ gist : & shared.Gist {
263+ Description : "some files" ,
264+ Files : map [string ]* shared.GistFile {
265+ "cicada.txt" : {
266+ Content : "bwhiizzzbwhuiiizzzz" ,
267+ Type : "text/plain" ,
268+ },
269+ },
270+ },
271+ wantOut : "cicada.txt\n " ,
272+ },
273+ {
274+ name : "multiple file, list files" ,
275+ opts : & ViewOptions {
276+ Selector : "1234" ,
277+ Raw : false ,
278+ ListFiles : true ,
279+ },
280+ gist : & shared.Gist {
281+ Description : "some files" ,
282+ Files : map [string ]* shared.GistFile {
283+ "cicada.txt" : {
284+ Content : "bwhiizzzbwhuiiizzzz" ,
285+ Type : "text/plain" ,
286+ },
287+ "foo.md" : {
288+ Content : "- foo" ,
289+ Type : "application/markdown" ,
290+ },
291+ },
292+ },
293+ wantOut : "cicada.txt\n foo.md\n " ,
294+ },
234295 }
235296
236297 for _ , tt := range tests {
0 commit comments