dorian-git-tree 0.5.3 → 1.1.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 +6 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b4ea2fed4f477b3acb304b9c92d9630dae06895a61cbcd1fa57acc9f7af62f23
4
- data.tar.gz: 370f32d4ce20a7277d49e2fd3304f4d561e2443f22629a1090040448b6becb53
3
+ metadata.gz: 337280e32b361b2da4147ef3e0045e4911525c4908a6c8b7b3ccfa68f628b39e
4
+ data.tar.gz: 451275eb2cdc74292237e6b9d208a308b080505acc7e9b2de8dd3173d65287a1
5
5
  SHA512:
6
- metadata.gz: 4b7d46f1c5ef0f74099ebc2db96ff831fda00a9fb5bd9f27aff9ab3cd45998ef3183748199fee17fbfdd5a68273eda33bbbfa5b1c1b03fd21f88110ea9708dee
7
- data.tar.gz: 5af8c8f974d61cd6e8d797dbeb0d1028a25d9224749f3fae04af56a21baa4bf9714caa127ee0c77579f5d9e18002bea0d9d1a98c826c762fc7240487bbc99295
6
+ metadata.gz: 7ac6959cd4aff84183d08e08859697ede04cddbd1535fde3d69644d31f26fb83aaf2bfb3d4930004b4b7cf78fd668d72421a5652718d821be82c7fd887e37d89
7
+ data.tar.gz: 8df6e922d3e61cd0f45cb59db7049d629763639a42d5430eb044cbd7c441045e129b4ea55e16a7ede4fb83ac33239cd2ceb02b7bb07000594ab5ff2c26740a67
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", __dir__))
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,17 +1,17 @@
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.1.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-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: git
14
+ name: dorian-arguments
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
@@ -25,7 +25,7 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: dorian-arguments
28
+ name: git
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
@@ -57,9 +57,9 @@ require_paths:
57
57
  - lib
58
58
  required_ruby_version: !ruby/object:Gem::Requirement
59
59
  requirements:
60
- - - ">="
60
+ - - '='
61
61
  - !ruby/object:Gem::Version
62
- version: '0'
62
+ version: 3.3.4
63
63
  required_rubygems_version: !ruby/object:Gem::Requirement
64
64
  requirements:
65
65
  - - ">="