@@ -120,8 +120,8 @@ pub struct Options {
120120 pub locality : Option < Locality > ,
121121 /// Gist command that's been issued.
122122 pub command : Command ,
123- /// Gist to operate on.
124- pub gist : GistArg ,
123+ /// Gist to operate on, if any .
124+ pub gist : Option < GistArg > ,
125125 /// Arguments to the gist, if any.
126126 /// This is only used if command == Command::Run.
127127 pub gist_args : Option < Vec < String > > ,
@@ -159,9 +159,10 @@ impl<'a> TryFrom<ArgMatches<'a>> for Options {
159159 let command = Command :: from_str ( cmd) . unwrap_or ( Command :: Run ) ;
160160
161161 // Parse out the gist argument.
162- let gist = try!( GistArg :: from_str (
163- cmd_matches. value_of ( ARG_GIST ) . unwrap ( )
164- ) ) ;
162+ let gist = match cmd_matches. value_of ( ARG_GIST ) {
163+ Some ( g) => Some ( try!( GistArg :: from_str ( g) ) ) ,
164+ None => None ,
165+ } ;
165166
166167 // For the "run" command, arguments may be provided.
167168 let mut gist_args = cmd_matches. values_of ( ARG_GIST_ARGV )
@@ -557,4 +558,12 @@ mod tests {
557558 assert ! ( parse_from_argv( args) . is_err( ) ,
558559 "\" help\" command was incorrectly treated as gist command" ) ;
559560 }
561+
562+ /// Verify that you can call the program with just the verbosity flags.
563+ #[ test]
564+ fn just_verbosity_works ( ) {
565+ let args = vec ! [ "gisht" , "-v" ] ;
566+ assert ! ( parse_from_argv( args) . is_ok( ) ,
567+ "Failed to parse command line with just the verbosity args" ) ;
568+ }
560569}
0 commit comments