Skip to content

Commit

Permalink
add dir and submodules commands
Browse files Browse the repository at this point in the history
  • Loading branch information
dorianmariecom committed Sep 6, 2024
1 parent 3eb536a commit 6aa8158
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions lib/dorian/bin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ def initialize
default: true
},
io: :string,
self: :boolean,
version: {
alias: :v
},
Expand Down Expand Up @@ -185,6 +186,14 @@ def run
arguments.delete("compare")
@command = :compare
command_compare
when :dir
arguments.delete("dir")
@command = :dir
command_dir
when :submodules
arguments.delete("submodules")
@command = :submodules
command_submodules
else
arguments.delete("read")
@command = :read
Expand Down Expand Up @@ -245,6 +254,36 @@ def everything
read_stdin_files + stdin_arguments + read_files + arguments
end

def command_dir
puts(
Git
.open(".")
.ls_files
.map(&:first)
.map { |path| path.split("/").first }
.select { |path| Dir.exist?(path) }
.reject { |path| path.start_with?(".") }
.sort
.uniq
)

puts "." if self?
end

def command_submodules
puts(
File.read(".gitmodules").lines.grep(/path = /).map do |path|
path.split("=").last.strip
end
)

puts "." if self?
end

def self?
!!options.self
end

def command_compare
file_1, file_2 = files
key_1, key_2 = arguments
Expand Down

0 comments on commit 6aa8158

Please sign in to comment.