dorian-git-tree 0.5.3 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/bin/git-tree +26 -23
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b4ea2fed4f477b3acb304b9c92d9630dae06895a61cbcd1fa57acc9f7af62f23
4
- data.tar.gz: 370f32d4ce20a7277d49e2fd3304f4d561e2443f22629a1090040448b6becb53
3
+ metadata.gz: aedd5baed50bded8a2697bd4c1f7f0668618ba3931024048fd8513f75a550825
4
+ data.tar.gz: 7ec98ad54a2d837f7d8b32e4cc83fab423b072ccbe784f7fb523c64dcec49d62
5
5
  SHA512:
6
- metadata.gz: 4b7d46f1c5ef0f74099ebc2db96ff831fda00a9fb5bd9f27aff9ab3cd45998ef3183748199fee17fbfdd5a68273eda33bbbfa5b1c1b03fd21f88110ea9708dee
7
- data.tar.gz: 5af8c8f974d61cd6e8d797dbeb0d1028a25d9224749f3fae04af56a21baa4bf9714caa127ee0c77579f5d9e18002bea0d9d1a98c826c762fc7240487bbc99295
6
+ metadata.gz: db7bd2dff7a976422eee9a5f981d45a42b0abbf19e2f92682bb40d9c37fa6fe9a7141c7bb2f3eef1d8692bd45337f998e8322ffc95e0498eca0db744171af601
7
+ data.tar.gz: 8763d8f59309cac4a5ace61424fdbd8300f0723f3f30c422968e842fe7fac32c1932df676d453e8bd634fa24c23d1bdf56a644ebc5db044fcc92f6636b514c9d
data/bin/git-tree CHANGED
@@ -2,6 +2,15 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require "git"
5
+ require "dorian/arguments"
6
+
7
+ parsed = Dorian::Arguments.parse(version: { alias: :v }, help: { alias: :h })
8
+
9
+ abort parsed.help if parsed.options.help
10
+
11
+ if parsed.options.version
12
+ abort File.read(File.expand_path("../../VERSION", __FILE__))
13
+ end
5
14
 
6
15
  SPACE = " "
7
16
  RIGHT = "└── "
@@ -38,27 +47,21 @@ def print(key:, values:, index: 0, size: 1, prefix: "")
38
47
  end
39
48
  end
40
49
 
41
- if ARGV[0] == "--help" || ARGV[0] == "-h" || ARGV.size > 1
42
- puts "USAGE: git tree [PATH]"
43
- exit
44
- end
45
-
46
- key = ARGV.first || "."
47
-
48
- files =
49
- git_ls_files(key).map { |file| ARGV.first ? file.sub(ARGV.first, "") : file }
50
-
51
- values = group(files)
52
-
53
- key = "#{key}/" if values.any? && key != "." && key[-1] != "/"
54
-
55
- puts key
56
-
57
- values.each.with_index do |(value_key, value_values), value_index|
58
- print(
59
- key: value_key,
60
- values: value_values,
61
- index: value_index,
62
- size: values.size
63
- )
50
+ keys = parsed.arguments.any? ? parsed.arguments : ["."]
51
+ keys.each do |key|
52
+ files =
53
+ git_ls_files(key).map do |file|
54
+ parsed.arguments.any? ? file.sub(key, "") : file
55
+ end
56
+ values = group(files)
57
+ key = "#{key}/" if values.any? && key != "." && key[-1] != "/"
58
+ puts key
59
+ values.each.with_index do |(value_key, value_values), value_index|
60
+ print(
61
+ key: value_key,
62
+ values: value_values,
63
+ index: value_index,
64
+ size: values.size
65
+ )
66
+ end
64
67
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dorian-git-tree
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dorian Marié
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-08-22 00:00:00.000000000 Z
11
+ date: 2024-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: git