@@ -30,42 +30,44 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
30
30
. help ( "Print section table" ) )
31
31
. get_matches ( ) ;
32
32
33
- if let Some ( file) = matches. get_one :: < String > ( "file" ) {
34
- const VERSION : & str = env ! ( "CARGO_PKG_VERSION" ) ;
35
- println ! ( "PE Parser - Version {}" , VERSION ) ;
36
- println ! ( "=========================\n " ) ;
37
-
38
- let binary = fs:: read ( file)
39
- . expect ( "Failed to read file" ) ;
40
-
41
- let pe = parse_portable_executable ( binary. as_slice ( ) )
42
- . expect ( "Failed to parse Portable Executable!" ) ;
33
+ match matches. get_one :: < String > ( "file" ) {
34
+ Some ( file) => {
35
+ const VERSION : & str = env ! ( "CARGO_PKG_VERSION" ) ;
36
+ println ! ( "PE Parser - Version {}" , VERSION ) ;
37
+ println ! ( "=========================\n " ) ;
43
38
44
- if matches. get_flag ( "all" ) {
45
- print ! ( "{}" , pe) ;
46
- } else {
47
- if matches. get_flag ( "coff" ) {
48
- println ! ( "{}" , pe. coff) ;
49
- }
50
-
51
- if matches. get_flag ( "optional" ) {
52
- if let Some ( optional) = pe. optional_header_32 {
53
- println ! ( "{}" , optional) ;
39
+ let binary = fs:: read ( file)
40
+ . expect ( "Failed to read file" ) ;
41
+
42
+ let pe = parse_portable_executable ( binary. as_slice ( ) )
43
+ . expect ( "Failed to parse Portable Executable!" ) ;
44
+
45
+ if matches. get_flag ( "all" ) {
46
+ print ! ( "{}" , pe) ;
47
+ } else {
48
+ if matches. get_flag ( "coff" ) {
49
+ println ! ( "{}" , pe. coff) ;
54
50
}
55
-
56
- if let Some ( optional) = pe. optional_header_64 {
57
- println ! ( "{}" , optional) ;
51
+
52
+ if matches. get_flag ( "optional" ) {
53
+ if let Some ( optional) = pe. optional_header_32 {
54
+ println ! ( "{}" , optional) ;
55
+ }
56
+
57
+ if let Some ( optional) = pe. optional_header_64 {
58
+ println ! ( "{}" , optional) ;
59
+ }
58
60
}
59
- }
60
-
61
- if matches . get_flag ( "section" ) {
62
- for section in pe . section_table . iter ( ) {
63
- println ! ( "{}" , section ) ;
61
+
62
+ if matches . get_flag ( "section" ) {
63
+ for section in pe . section_table . iter ( ) {
64
+ println ! ( "{}" , section ) ;
65
+ }
64
66
}
65
67
}
68
+ } _ => {
69
+ println ! ( "No PE file passed to parse!" ) ;
66
70
}
67
- } else {
68
- println ! ( "No PE file passed to parse!" ) ;
69
71
} ;
70
72
71
73
Ok ( ( ) )
0 commit comments