micromenu 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/bin/um +86 -0
- metadata +60 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7b99abda368b7653a9d096fd6af0d233872fdc0f54ae85014ead92d2e6a52d48
|
4
|
+
data.tar.gz: 5e09c5b87776f10ee220c751e6fa66e52a10d9ab73b5bad8eac672be64a7dddd
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e87da796498d324701d418854371385aec6b2c5fad7a75f7d9b0b64bff88df1847093b281558a5d0391c06ae243b3053694ea555a384bc7c0902efc1f80d57e0
|
7
|
+
data.tar.gz: c0edf467e14dcf99a3152cbb9588a72a7a7920a87eeedf46f63b0ea775e11187f367c9d800838b8836c82d47835e77b4a6a8f44a30f5bccb982183c2b497a32e
|
data/bin/um
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'tty-prompt'
|
4
|
+
|
5
|
+
home = Dir.getwd
|
6
|
+
|
7
|
+
if ARGV.length > 0
|
8
|
+
# if the first argument looks like something other than a string
|
9
|
+
if ARGV[0].to_i.to_s != ARGV[0]
|
10
|
+
dir = ARGV.shift
|
11
|
+
Dir.chdir dir
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def bye
|
16
|
+
puts
|
17
|
+
puts "Bye!"
|
18
|
+
exit
|
19
|
+
end
|
20
|
+
|
21
|
+
def prompt
|
22
|
+
$prompt ||= begin
|
23
|
+
p = TTY::Prompt.new(interrupt: :signal)
|
24
|
+
p.on(:keypress) do |event|
|
25
|
+
if event.value.to_i.to_s == event.value
|
26
|
+
p.trigger(:keyenter)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
p.on(:keyescape) do |event|
|
30
|
+
bye
|
31
|
+
end
|
32
|
+
p
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def choose(options)
|
37
|
+
if ARGV.length > 0
|
38
|
+
ARGV.shift
|
39
|
+
else
|
40
|
+
begin
|
41
|
+
help = "(Use ↑/↓ arrow keys or numbers to select)"
|
42
|
+
prompt.select('Select an action:', options, enum: ')', cycle: true, help: help)
|
43
|
+
rescue TTY::Reader::InputInterrupt
|
44
|
+
bye
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def args
|
50
|
+
if ARGV.length > 0
|
51
|
+
ARGV
|
52
|
+
else
|
53
|
+
prompt.ask('Arguments:')&.split || []
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
Kernel.trap( "INT" ) { bye }
|
58
|
+
|
59
|
+
puts "✨ μMenu ✨"
|
60
|
+
|
61
|
+
loop do
|
62
|
+
files = Dir.glob('*').sort
|
63
|
+
|
64
|
+
dirs = files.select { |f| File.directory? f }
|
65
|
+
execs = files.select { |f| File.executable? f } - dirs
|
66
|
+
list = dirs + execs
|
67
|
+
exit if list.empty?
|
68
|
+
|
69
|
+
options = list.map.with_index do |name, value|
|
70
|
+
{
|
71
|
+
name: dirs.include?(name) ? "📁 #{name}" : name,
|
72
|
+
value: value + 1
|
73
|
+
}
|
74
|
+
end
|
75
|
+
|
76
|
+
choice = list[choose(options).to_i - 1]
|
77
|
+
puts "⤷ #{choice}"
|
78
|
+
|
79
|
+
if dirs.include?(choice)
|
80
|
+
Dir.chdir choice
|
81
|
+
else
|
82
|
+
system(File.expand_path(choice), *args)
|
83
|
+
Dir.chdir home
|
84
|
+
exit
|
85
|
+
end
|
86
|
+
end
|
metadata
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: micromenu
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tristan Penman
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-05-13 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: tty-prompt
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.23.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.23.1
|
27
|
+
description: A cute little menu system written in Ruby. Run this in any directory
|
28
|
+
to show a file listing with just sub-directories and executable files. Navigation
|
29
|
+
can be quickened by providing your selection as command line arguments.
|
30
|
+
email: tristan@tristanpenman.com
|
31
|
+
executables:
|
32
|
+
- um
|
33
|
+
extensions: []
|
34
|
+
extra_rdoc_files: []
|
35
|
+
files:
|
36
|
+
- bin/um
|
37
|
+
homepage: https://github.com/tristanpenman/micromenu
|
38
|
+
licenses:
|
39
|
+
- MIT
|
40
|
+
metadata: {}
|
41
|
+
post_install_message:
|
42
|
+
rdoc_options: []
|
43
|
+
require_paths:
|
44
|
+
- lib
|
45
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
requirements: []
|
56
|
+
rubygems_version: 3.0.9
|
57
|
+
signing_key:
|
58
|
+
specification_version: 4
|
59
|
+
summary: "A cute little menu system written in Ruby \U0001F970"
|
60
|
+
test_files: []
|