diff options
| author | Joshua Peek <josh@joshpeek.com> | 2011-05-25 13:12:24 -0500 |
|---|---|---|
| committer | Joshua Peek <josh@joshpeek.com> | 2011-05-25 13:12:24 -0500 |
| commit | 31f5882774b0e39de21ee85b1aebecd0460c9705 (patch) | |
| tree | 3bf94ea6372e3dbd96889901719db39a75474878 /bin | |
| parent | a00013a077dbc2a12a7a98a8e914b2330bac276d (diff) | |
Add file inspection to bin
Diffstat (limited to 'bin')
| -rwxr-xr-x | bin/linguist | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/bin/linguist b/bin/linguist index ba31f7b..7b7cb88 100755 --- a/bin/linguist +++ b/bin/linguist @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -require 'linguist/blob' +require 'linguist/file_blob' require 'linguist/repository' path = ARGV[0] || Dir.pwd @@ -11,6 +11,36 @@ if File.directory?(path) percentage = ((size / repo.size.to_f) * 100).round puts "%-4s %s" % ["#{percentage}%", language] end +elsif File.file?(path) + blob = Linguist::FileBlob.new(path, Dir.pwd) + type = if blob.text? + 'Text' + elsif blob.image? + 'Image' + elsif blob.binary? + 'Binary' + else + '???' + end + + puts "#{blob.name}: #{blob.loc} lines (#{blob.sloc} sloc)" + puts " type: #{type}" + puts " extension: #{blob.pathname.extname}" + puts " mime type: #{blob.mime_type}" + puts " content type: #{blob.content_type}" + puts " language: #{blob.language}" + + if blob.large? + puts " large (blob is too large to be shown" + end + + if blob.generated? + puts " appears to be generated source code" + end + + if blob.vendored? + puts " appears to be a vendored file" + end else abort "usage: linguist <path>" end |
