Allow using wildcard mime types when copying from clipboard

This commit is contained in:
Kovid Goyal 2022-12-03 14:06:16 +05:30
parent 5c9c9a67bc
commit b644a42a48
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
2 changed files with 9 additions and 1 deletions

View file

@ -22,7 +22,9 @@
The mimetype of the specified file. Useful when the auto-detected mimetype is
likely to be incorrect or the filename has no extension and therefore no mimetype
can be detected. If more than one file is specified, this option should be specified multiple
times, once for each specified file.
times, once for each specified file. When copying data from the clipboard, you can use wildcards
to match MIME types. For example: :code:`--mime 'text/*'` will match any textual MIME type
available on the clipboard, usually the first matching MIME type is copied.
--alias -a

View file

@ -156,6 +156,12 @@ func (self *Output) assign_mime_type(available_mimes []string, aliases map[strin
}
}
}
for _, mt := range available_mimes {
if matched, _ := filepath.Match(self.mime_type, mt); matched {
self.remote_mime_type = mt
return
}
}
if images.EncodableImageTypes[self.mime_type] {
for _, mt := range available_mimes {
if images.DecodableImageTypes[mt] {