-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
completion: exif #8246
completion: exif #8246
Conversation
Adds completion support for the exif command line tool (upstream: https://github.com/libexif/exif).
share/completions/exif.fish
Outdated
end | ||
|
||
function __get_target_files_tags | ||
string trim (string split -m1 ' ' (string replace -r '(\s+[-*]){5}' '' (string replace -fr '^(?!EXIF)' '' (exif --list-tags (__get_target_files))))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exif --list-tags (__get_target_files) | string replace -fr '^(?!EXIF)' '' | string replace -r '(\s+[-*]){5}' '' | string split -m1 ' ' | string trim
Also the (\s+[-*]){5}
seems a bit brittle. Can you give some example output here, maybe we can figure out a more robust regex?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, here's some example output:
EXIF tags in 'IMG_3146.JPG': 0 1 EXIF GPS Interop
0x0000 GPS Tag Version - - - - -
0x0001 Interoperability Index - - - - -
0x0002 Interoperability Version - - - - -
0x0003 East or West Longitude - - - - -
0x0004 Longitude - - - - -
0x0005 Altitude Reference - - - - -
0x0006 Altitude - - - - -
0x0007 GPS Time (Atomic Clock) - - - - -
0x0008 GPS Satellites - - - - -
0x0009 GPS Receiver Status - - - - -
0x000a GPS Measurement Mode - - - - -
0x000b Measurement Precision - - - - -
0x000c Speed Unit - - - - -
0x000d Speed of GPS Receiver - - - - -
0x000e Reference for direction of movement - - - - -
0x000f Direction of Movement - - - - -
0x0010 GPS Image Direction Reference - - - - -
0x0011 GPS Image Direction - - - - -
0x0012 Geodetic Survey Data Used - - - - -
0x0013 Reference For Latitude of Destination - - - - -
0x0014 Latitude of Destination - - - - -
0x0015 Reference for Longitude of Destinatio - - - - -
0x0016 Longitude of Destination - - - - -
0x0017 Reference for Bearing of Destination - - - - -
0x0018 Bearing of Destination - - - - -
0x0019 Reference for Distance to Destination - - - - -
0x001a Distance to Destination - - - - -
0x001b Name of GPS Processing Method - - - - -
0x001c Name of GPS Area - - - - -
0x001d GPS Date - - - - -
0x001e GPS Differential Correction - - - - -
0x001f GPS Horizontal Positioning Error - - - - -
0x00fe New Subfile Type - - - - -
0x0100 Image Width - - - - -
0x0101 Image Length - - - - -
0x0102 Bits per Sample - - - - -
0x0103 Compression - * - - -
0x0106 Photometric Interpretation - - - - -
0x010a Fill Order - - - - -
0x010d Document Name - - - - -
0x010e Image Description - - - - -
0x010f Manufacturer * - - - -
0x0110 Model * - - - -
0x0111 Strip Offsets - - - - -
0x0112 Orientation * - - - -
0x0115 Samples per Pixel - - - - -
0x0116 Rows per Strip - - - - -
0x0117 Strip Byte Count - - - - -
0x011a X-Resolution * * - - -
0x011b Y-Resolution * * - - -
0x011c Planar Configuration - - - - -
0x0128 Resolution Unit * * - - -
0x012d Transfer Function - - - - -
0x0131 Software * - - - -
0x0132 Date and Time * - - - -
0x013b Artist - - - - -
0x013e White Point - - - - -
0x013f Primary Chromaticities - - - - -
0x014a SubIFD Offsets - - - - -
0x0156 Transfer Range - - - - -
0x0200 JPEGProc - - - - -
0x0201 JPEG Interchange Format - - - - -
0x0202 JPEG Interchange Format Length - - - - -
0x0211 YCbCr Coefficients - - - - -
0x0212 YCbCr Sub-Sampling - - - - -
0x0213 YCbCr Positioning * - - - -
0x0214 Reference Black/White - - - - -
0x02bc XML Packet - - - - -
0x1000 RelatedImageFileFormat - - - - -
0x1001 RelatedImageWidth - - - - -
0x1002 RelatedImageLength - - - - -
0x828d CFARepeatPatternDim - - - - -
0x828e CFA Pattern - - - - -
0x828f Battery Level - - - - -
0x8298 Copyright - - - - -
0x829a Exposure Time - - * - -
0x829d F-Number - - * - -
0x83bb IPTC/NAA - - - - -
0x8649 Image Resources Block - - - - -
0x8773 InterColorProfile - - - - -
0x8822 Exposure Program - - * - -
0x8824 Spectral Sensitivity - - - - -
0x8827 ISO Speed Ratings - - * - -
0x8828 Opto-Electronic Conversion Function - - - - -
0x882a Time Zone Offset - - - - -
0x9000 Exif Version - - * - -
0x9003 Date and Time (Original) - - * - -
0x9004 Date and Time (Digitized) - - * - -
0x9101 Components Configuration - - * - -
0x9102 Compressed Bits per Pixel - - - - -
0x9201 Shutter Speed - - * - -
0x9202 Aperture - - * - -
0x9203 Brightness - - * - -
0x9204 Exposure Bias - - * - -
0x9205 Maximum Aperture Value - - - - -
0x9206 Subject Distance - - - - -
0x9207 Metering Mode - - * - -
0x9208 Light Source - - - - -
0x9209 Flash - - * - -
0x920a Focal Length - - * - -
0x9214 Subject Area - - * - -
0x9216 TIFF/EP Standard ID - - - - -
0x927c Maker Note - - * - -
0x9286 User Comment - - - - -
0x9290 Sub-second Time - - - - -
0x9291 Sub-second Time (Original) - - * - -
0x9292 Sub-second Time (Digitized) - - * - -
0x9c9b XP Title - - - - -
0x9c9c XP Comment - - - - -
0x9c9d XP Author - - - - -
0x9c9e XP Keywords - - - - -
0x9c9f XP Subject - - - - -
0xa000 FlashPixVersion - - * - -
0xa001 Colour Space - - * - -
0xa002 Pixel X Dimension - - * - -
0xa003 Pixel Y Dimension - - * - -
0xa004 Related Sound File - - - - -
0xa20b Flash Energy - - - - -
0xa20c Spatial Frequency Response - - - - -
0xa20e Focal Plane X-Resolution - - - - -
0xa20f Focal Plane Y-Resolution - - - - -
0xa210 Focal Plane Resolution Unit - - - - -
0xa214 Subject Location - - - - -
0xa215 Exposure Index - - - - -
0xa217 Sensing Method - - * - -
0xa300 File Source - - - - -
0xa301 Scene Type - - * - -
0xa302 CFA Pattern - - - - -
0xa401 Custom Rendered - - - - -
0xa402 Exposure Mode - - * - -
0xa403 White Balance - - * - -
0xa404 Digital Zoom Ratio - - * - -
0xa405 Focal Length in 35mm Film - - * - -
0xa406 Scene Capture Type - - * - -
0xa407 Gain Control - - - - -
0xa408 Contrast - - - - -
0xa409 Saturation - - - - -
0xa40a Sharpness - - - - -
0xa40b Device Setting Description - - - - -
0xa40c Subject Distance Range - - - - -
0xa420 Image Unique ID - - - - -
0xa430 Camera Owner Name - - - - -
0xa431 Body Serial Number - - - - -
0xa432 Lens Specification - - * - -
0xa433 Lens Make - - * - -
0xa434 Lens Model - - * - -
0xa435 Lens Serial Number - - - - -
0xa460 Composite Image - - * - -
0xa461 Source Image Number Of Composite Imag - - - - -
0xa462 Source Exposure Times of Composite Im - - - - -
0xa500 Gamma - - - - -
0xc4a5 PRINT Image Matching - - - - -
0xea1c Padding - - - - -
The output seems reasonnably consistent, but I haven't taken a look at exif's source code or anything, so there may be edge cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, while working on this I realized that I missed an important part of this which was filtering out empty tags, so that regex definitely has to go, the same issue of how reliable the output is will show up in the new implementation though.
share/completions/exif.fish
Outdated
switch (string lower "$sub_parts[2]") | ||
case "tag" | ||
if test -n "$short" | ||
complete -c exif -s "$short" -l "$long" -d "$description" -x -a "(__get_target_files_tags)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This just generates the completions. Honestly, typically I prefer hand-rolled completions because it allows you to tweak the descriptions.
You could just use the output of this and improve it, instead of running this all the time with a bunch of regexes that break the next time exif
switches its output formatting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose it's not super pretty, but from what I can see from the source code, exif
uses the popt library, so I don't think the output is likely to change formatting, and this method should survive changes to exif's functionality after the change in 936c984 to handle miscellaneous required argument names.
Adds completion support for the exif command line tool (upstream: https://github.com/libexif/exif).
merged as 25b9568, thanks! |
Description
Adds completion support for the exif command line tool (upstream: https://github.com/libexif/exif).
Fixes issue #TODOs: