Skip to content

Commit 9b04739

Browse files
committed
mash pkgxdev/ls
1 parent b620a84 commit 9b04739

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

scripts/ls

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/usr/bin/env -S pkgx +gum +gem bash
2+
3+
ruby "$0" | gum format
4+
exit 0
5+
6+
#!/usr/bin/ruby
7+
require 'pathname'
8+
9+
def find_versions(dir, result)
10+
Dir.foreach(dir) do |entry|
11+
next if entry == '.' || entry == '..' # Skip current and parent directories
12+
13+
path = File.join(dir, entry)
14+
15+
if File.directory?(path) && !File.symlink?(path)
16+
if entry =~ /^v\d+\./
17+
version = entry.sub(/^v/, '')
18+
parent_dir = Pathname.new(dir).relative_path_from($pkgx_dir)
19+
result << "| #{parent_dir} | #{version} |"
20+
else
21+
find_versions(path, result) # Recursively call for subdirectories
22+
end
23+
end
24+
end
25+
end
26+
27+
# Define the path to the .pkgx directory
28+
$pkgx_dir = File.expand_path('~/.pkgx')
29+
result = []
30+
31+
# Start the recursive search
32+
find_versions($pkgx_dir, result)
33+
34+
# Output the Markdown table
35+
puts "| Parent Directory | Version |"
36+
puts "|------------------|---------|"
37+
puts result.join("\n")

0 commit comments

Comments
 (0)