add short output
This commit is contained in:
parent
5add145cef
commit
b9e61ef101
@ -2,6 +2,7 @@ require "colorize"
|
||||
require "option_parser"
|
||||
|
||||
VERSION = {{ `shards version "#{__DIR__}"`.chomp.stringify }}
|
||||
short_output = false
|
||||
|
||||
begin
|
||||
OptionParser.parse do |parser|
|
||||
@ -12,6 +13,10 @@ begin
|
||||
exit(0)
|
||||
end
|
||||
|
||||
parser.on "-s", "Short output" do
|
||||
short_output = true
|
||||
end
|
||||
|
||||
parser.on "-v", "Show version" do
|
||||
puts VERSION
|
||||
exit(0)
|
||||
@ -28,7 +33,7 @@ if File.exists?(CONFIG_PATH)
|
||||
|
||||
repos_dirs = File.read_lines(CONFIG_PATH)
|
||||
|
||||
repos_dirs.each { |x| check_repo(x) }
|
||||
repos_dirs.each { |x| check_repo(x, short_output) }
|
||||
else
|
||||
Dir.mkdir_p(File.dirname(CONFIG_PATH))
|
||||
File.new(CONFIG_PATH, "w")
|
||||
@ -37,7 +42,7 @@ else
|
||||
puts " directory created.\n"
|
||||
end
|
||||
|
||||
def check_repo(repo_path : String)
|
||||
def check_repo(repo_path : String, show_path)
|
||||
if !Dir.exists?(repo_path.sub("$HOME", ENV["HOME"]))
|
||||
return 0
|
||||
end
|
||||
@ -52,8 +57,13 @@ def check_repo(repo_path : String)
|
||||
if !ahead_count.empty?
|
||||
print "* #{ahead_count}\t".colorize(:red).mode(:bold)
|
||||
print repo_name.colorize(:yellow)
|
||||
|
||||
if !show_path
|
||||
print " ["
|
||||
print repo_path.colorize(:light_magenta)
|
||||
puts "]"
|
||||
else
|
||||
puts
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user