You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
mime ... the detected MIME types associated with the file,
58
-
like the output of the `file` command
59
-
html ... an interactive HTML-based hex viewer
60
-
json ... a modified version of the SBUD format in JSON syntax
61
-
sbud ... equivalent to 'json'
62
-
79
+
file ...... the detected formats associated with the file,
80
+
like the output of the `file` command
81
+
mime ...... the detected MIME types associated with the file,
82
+
like the output of the `file --mime-type` command
83
+
explain ... like 'mime', but adds a human-readable explanation
84
+
for why each MIME type matched
85
+
html ...... an interactive HTML-based hex viewer
86
+
json ...... a modified version of the SBUD format in JSON syntax
87
+
sbud ...... equivalent to 'json'
88
+
63
89
Multiple formats can be output at once:
64
-
90
+
65
91
polyfile INPUT_FILE -f mime -f json
66
-
92
+
67
93
Their output will be concatenated to STDOUT in the order that
68
94
they occur in the arguments.
69
-
95
+
70
96
To save each format to a separate file, see the `--output` argument.
71
-
72
-
If no format is specified, PolyFile defaults to `--format sbud`,
73
-
but this will change to `--format mime` in v0.5.0
97
+
98
+
If no format is specified, PolyFile defaults to `--format file`
74
99
--output OUTPUT, -o OUTPUT
75
100
an optional output path for `--format`
76
-
101
+
77
102
Each instance of `--output` applies to the previous instance
78
103
of the `--format` option.
79
-
104
+
80
105
For example:
81
-
106
+
82
107
polyfile INPUT_FILE --format html --output output.html \
83
108
--format sbud --output output.json
84
-
109
+
85
110
will save HTML to to `output.html` and SBUD to `output.json`.
86
111
No two outputs can be directed at the same file path.
87
-
112
+
88
113
The path can be '-' for STDOUT.
89
114
If an `--output` is omitted for a format,
90
115
then it will implicitly be printed to STDOUT.
@@ -93,6 +118,7 @@ optional arguments:
93
118
--list, -l list the supported filetypes for the `--filetype` argument and exit
94
119
--html HTML, -t HTML path to write an interactive HTML file for exploring the PDF;
95
120
equivalent to `--format html --output HTML`
121
+
--explain equivalent to `--format explain
96
122
--only-match-mime, -I
97
123
"just print out the matching MIME types for the file, one on each line;
98
124
equivalent to `--format mime`
@@ -101,6 +127,8 @@ optional arguments:
101
127
--max-matches MAX_MATCHES
102
128
stop scanning after having found this many matches
103
129
--debugger, -db drop into an interactive debugger for libmagic file definition matching and PolyFile parsing
130
+
--eval-command EVAL_COMMAND, -ex EVAL_COMMAND
131
+
execute the given debugger command
104
132
--no-debug-python by default, the `--debugger` option will break on custom matchers and prompt to debug using PDB. This option will suppress those prompts.
105
133
--quiet, -q suppress all log output
106
134
--debug, -d print debug information
@@ -109,17 +137,6 @@ optional arguments:
109
137
-dumpversion print PolyFile's raw version information to STDOUT and exit
110
138
```
111
139
112
-
To generate a JSON mapping of a file, run:
113
-
114
-
```
115
-
polyfile INPUT_FILE > output.json
116
-
```
117
-
118
-
You can optionally have PolyFile output an interactive HTML page containing a labeled, interactive hexdump of the file:
Prior to PolyFile version 0.3.0, it used the [TrID database](http://mark0.net/soft-trid-deflist.html) for file
@@ -150,13 +167,7 @@ TrID matching code is still shipped with PolyFile and can be invoked programmati
150
167
151
168
### Output Format
152
169
153
-
PolyFile outputs its mapping in an extension of the [SBuD](https://github.com/corkami/sbud) JSON format described [in the documentation](docs/json_format.md).
154
-
155
-
PolyFile can also emit a standalone HTML document that contains an interactive hex viewer as well as syntax trees for
156
-
the discovered file formats. Simply pass the `--html` argument to PolyFile with an output path:
157
-
```console
158
-
$ polyfile input_file --html output.html
159
-
```
170
+
PolyFile has several options for outputting its results, specified by its `--format` option. For computer-readable output, PolyFile has an extension of the [SBuD](https://github.com/corkami/sbud) JSON format described [in the documentation](docs/json_format.md). Prior to version 0.5.0 this was the default output format of PolyFile. However, now the default output format is to mimic the behavior of the `file` command. To maintain the original behavior, use the `--format sbud` option.
0 commit comments