diff --git a/bin/git-linguist b/bin/git-linguist index d390530e..510354f4 100755 --- a/bin/git-linguist +++ b/bin/git-linguist @@ -1,5 +1,7 @@ #!/usr/bin/env ruby +$LOAD_PATH[0, 0] = File.join(File.dirname(__FILE__), '..', 'lib') + require 'linguist' require 'rugged' require 'optparse' @@ -102,10 +104,16 @@ def git_linguist(args) commit = nil parser = OptionParser.new do |opts| - opts.banner = "Usage: git-linguist [OPTIONS] stats|breakdown|dump-cache|clear|disable" + opts.banner = <<-HELP + Linguist v#{Linguist::VERSION} + Detect language type and determine language breakdown for a given Git repository. + + Usage: + git-linguist [OPTIONS] stats|breakdown|dump-cache|clear|disable" + HELP opts.on("-f", "--force", "Force a full rescan") { incremental = false } - opts.on("--commit=COMMIT", "Commit to index") { |v| commit = v} + opts.on("-c", "--commit=COMMIT", "Commit to index") { |v| commit = v} end parser.parse!(args) diff --git a/bin/linguist b/bin/linguist index ee1b2124..d20c9d6f 100755 --- a/bin/linguist +++ b/bin/linguist @@ -1,18 +1,22 @@ #!/usr/bin/env ruby -# linguist — detect language type for a file, or, given a directory, determine language breakdown -# usage: linguist [<--breakdown>] -# +$LOAD_PATH[0, 0] = File.join(File.dirname(__FILE__), '..', 'lib') + require 'linguist' require 'rugged' require 'json' +require 'optparse' path = ARGV[0] || Dir.pwd -# special case if not given a directory but still given the --breakdown option +# special case if not given a directory +# but still given the --breakdown or --json options/ if path == "--breakdown" path = Dir.pwd breakdown = true +elsif path == "--json" + path = Dir.pwd + json_breakdown = true end ARGV.shift @@ -69,5 +73,12 @@ elsif File.file?(path) puts " appears to be a vendored file" end else - abort "usage: linguist " + abort <<-HELP + Linguist v#{Linguist::VERSION} + Detect language type for a file, or, given a directory, determine language breakdown. + + Usage: linguist + linguist [--breakdown] [--json] + linguist [--breakdown] [--json] + HELP end