mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
37 lines
695 B
Ruby
Executable File
37 lines
695 B
Ruby
Executable File
#!/usr/bin/env ruby
|
|
|
|
require "optparse"
|
|
require_relative "./helpers/submodule"
|
|
|
|
usage = <<-EOH
|
|
Usage:
|
|
#{$0} [-t|--test] [-h|--help]
|
|
|
|
Examples:
|
|
#{$0} # Update .gitmodules file in-place
|
|
#{$0} --help # Display this help message
|
|
#{$0} --test # Exit with an error code if .gitmodules needs sorting
|
|
EOH
|
|
|
|
$testing = false
|
|
|
|
OptionParser.new do |opts|
|
|
opts.banner = usage
|
|
opts.on("-h", "--help") do
|
|
puts usage
|
|
exit
|
|
end
|
|
opts.on("-t", "--test", "Don't update file; only test if it's unsorted") do
|
|
$testing = true
|
|
end
|
|
end.parse!
|
|
|
|
unsorted = read ".gitmodules"
|
|
sorted = Submodule.list.join
|
|
|
|
if $testing
|
|
exit unsorted == sorted
|
|
else
|
|
write ".gitmodules", sorted
|
|
end
|