u-menu 0.6.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3cfb79ad584788fb2205a567eef99fac9881cb7aac9bef195be99062de4f8af4
4
- data.tar.gz: ec105fc48dcd1520dfdd7320f3f0c194ce2ede0dba0f3fc880963ff4d4513b0e
3
+ metadata.gz: 752e9401c942d535e54ba495ed964ec8c75b39b43a88b1eade2fc41ee9363ceb
4
+ data.tar.gz: 76a095e14abf9b1e96ea75995eeea37d59b29d67bb1c4e4c25b8af91798a62bd
5
5
  SHA512:
6
- metadata.gz: e8c7e430dca9ed7b865b8a0a9a384ed5f10419963487bde9d86a43f7b0e4cce788b55a9ba8d51bc71578a761c7e81ec29096eb91b5e649e22da20036c5237466
7
- data.tar.gz: eb9f1f36bb549c73836306a15d87de2741acf0313fc3822f43ef353fcd222da01205de5ccaf4fdf99e2dc74f05e7616ed6c52622f4008d4ee8dfecb4df94c691
6
+ metadata.gz: 0ffe250fa89b1165dd6861793b72146e000fcde4a8528fe0bcfb1ea8eff7b42fb790d0c724d8b4e9ebd96be94e3169be0ea201dde3226eac4426793612320f94
7
+ data.tar.gz: '08d802fd502f95d5607e780cfeb1dfa9924d3e79bf497222db104dfe2be631d9db21e32b074b4c355a2e5133f24ba7a2800d9d15677d2e422af10d06f932c9d6'
data/bin/u-menu CHANGED
@@ -4,48 +4,53 @@ require_relative '../lib/u-menu'
4
4
 
5
5
  require 'tty-prompt'
6
6
 
7
- config = Micro::Menu.configurations.load
7
+ command = ARGV.first
8
8
 
9
- colors = Micro::Menu.colors
10
- prompt = TTY::Prompt.new(prefix: colors.magenta("\uea85 \u00b5menu "), interrupt: :signal)
9
+ if command == 'init'
10
+ puts "\n\nCreating a simple config file at ``"
11
+ Micro::Menu.configurations.init
12
+ end
11
13
 
14
+ config = Micro::Menu.configurations.load
15
+ colors = Micro::Menu.colors
12
16
  icons = Micro::Menu.icons.all
13
-
14
- thanks = [
15
- colors.green('Great job! o/'),
16
- colors.green('See you later! =)'),
17
- colors.green('Baby bye bye bye...'),
18
- "Bring me #{colors.green('a cookie')} when you come back!?",
19
- "Have a nice #{colors.cyan('day')}! =)",
20
- "See you later #{colors.green('olligator')}! =)"
21
- ]
17
+ messages = Micro::Menu.messages
22
18
 
23
19
  trap('INT') do
20
+ thanks = messages.thanks
21
+
24
22
  puts "\n\n#{thanks.sample}"
25
23
  exit(0)
26
24
  end
27
25
 
28
- action = nil
29
- title, options = config.values_at(:title, :options)
26
+ title, options, use_icons =
27
+ config.values_at(:title, :options, :use_icons)
28
+
29
+ use_icons ||= false
30
30
 
31
+ prompt = TTY::Prompt.new(
32
+ prefix: colors.magenta("#{use_icons ? "\uea85" : ''} u-menu "),
33
+ interrupt: :signal
34
+ )
35
+
36
+ # create a default edit settings option
31
37
  options << {
32
- name: '{{settings}} Edit Settings',
33
- type: 'edit',
34
- value: 'settings',
35
- execute: config[:_path]
38
+ name: '{{settings}} Edit Settings', type: 'edit', value: 'settings', execute: config[:_path]
36
39
  }
40
+
37
41
  options = options.sort { |a, b| a[:name] <=> b[:name] }
38
42
 
39
43
  options.each do |option|
40
44
  if option[:name].match(/\{\{(?<icon_name>.*)\}\}/)
41
45
  icon_name = Regexp.last_match('icon_name')
42
- option[:name].sub!("{{#{icon_name}}}", icons[icon_name])
46
+ option[:name].sub!("{{#{icon_name}}} ", use_icons ? icons[icon_name] : '')
43
47
  else
44
- option[:name] = "#{icons['terminal']} #{option[:name]}" if option[:type] == 'command'
45
- option[:name] = "#{icons['link']} #{option[:name]}" if option[:type] == 'link'
48
+ option[:name] = "#{use_icons ? icons['terminal'] : ''} #{option[:name]}" if option[:type] == 'command'
49
+ option[:name] = "#{use_icons ? icons['link'] : ''} #{option[:name]}" if option[:type] == 'link'
46
50
  end
47
51
  end
48
52
 
53
+ action = nil
49
54
  loop do
50
55
  choice = prompt.select(title, options, filter: true)
51
56
  action = config[:options].find { |item| item[:value] == choice }
@@ -4,16 +4,74 @@ require 'yaml'
4
4
 
5
5
  module Micro
6
6
  module Menu
7
+ # Configuration module
8
+ # @private
7
9
  module Configurations
8
10
  CONFIGURATION_PATHS = [
9
11
  File.expand_path("#{Dir.home}/.umenurc.yml", __dir__),
10
- File.expand_path("#{Dir.home}/.umenu/umenurc.yml", __dir__),
12
+ File.expand_path("#{Dir.home}/.umenu/umenurc.yml", __dir__)
11
13
  ]
12
14
 
13
- def self.load
14
- path = CONFIGURATION_PATHS.first { |file_path| File.exist? file_path }
15
- @@config = YAML.load_file(path, symbolize_names: true)
16
- @@config.update(_path: path)
15
+ class << self
16
+ def load
17
+ path = CONFIGURATION_PATHS.first { |file_path| File.exist? file_path }
18
+ @@config = YAML.load_file(path, symbolize_names: true)
19
+ @@config.update(_path: path)
20
+ end
21
+
22
+ def init(path = nil)
23
+ path ||= CONFIGURATION_PATHS.first
24
+ return if File.exist?(path)
25
+
26
+ File.write(path, <<~CONFIG)
27
+ ---
28
+ version: 0.1
29
+ title: apps
30
+ settings:
31
+ editor: 'nvim'
32
+ options:
33
+ - name: 'DuckDuckGo /Search'
34
+ value: duckduckgo
35
+ type: link
36
+ execute: 'https://duckduckgo.com'
37
+ - name: '{{github}} Github'
38
+ value: github
39
+ type: link
40
+ execute: 'https://github.com'
41
+ - name: '{{github}} Github /Pull Requests'
42
+ value: github_pulls
43
+ type: link
44
+ execute: 'https://github.com/pulls?q=is%3Apr+is%3Aopen+author%3A%40me+archived%3Afalse+sort%3Aupdated-desc'
45
+ - name: '{{github}} Github /Issues'
46
+ value: github_issues
47
+ type: link
48
+ execute: 'https://github.com/issues?q=is%3Aissue+is%3Aopen+author%3A%40me+archived%3Afalse+sort%3Aupdated-desc'
49
+ - name: '{{github}} Github /Profile'
50
+ value: github_profile
51
+ type: link
52
+ execute: 'https://github.com/dvinciguerra'
53
+ - name: 'Rubygems'
54
+ value: rubygems
55
+ type: link
56
+ execute: 'https://rubygems.org'
57
+ - name: 'File Explorer'
58
+ value: files
59
+ type: command
60
+ execute: 'ranger ${pwd}'
61
+ - name: 'Tmux'
62
+ value: tmux
63
+ type: command
64
+ execute: 'tmux'
65
+ - name: 'Tmux /New Window'
66
+ value: tmux_new_window
67
+ type: command
68
+ execute: 'tmux new-window'
69
+ - name: 'Tmux /Kill Window'
70
+ value: tmux_kill_window
71
+ type: command
72
+ execute: 'tmux kill-window'
73
+ CONFIG
74
+ end
17
75
  end
18
76
  end
19
77
  end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+
4
+ module Micro
5
+ module Menu
6
+ module Messages
7
+ class << self
8
+ def thanks
9
+ [
10
+ colors.green('Great job! o/'),
11
+ colors.green('See you later! =)'),
12
+ colors.green('Baby bye bye bye...'),
13
+ "Bring me #{colors.green('a cookie')} when you come back!?",
14
+ "Have a nice #{colors.cyan('day')}! =)",
15
+ "See you later #{colors.green('olligator')}! =)"
16
+ ]
17
+ end
18
+
19
+ private
20
+
21
+ def colors
22
+ Micro::Menu.colors
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Micro
4
4
  module Menu
5
- VERSION = '0.6.0'
5
+ VERSION = '0.8.0'
6
6
  end
7
7
  end
data/lib/micro/menu.rb CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  require_relative 'menu/configurations'
4
4
  require_relative 'menu/icons'
5
+ require_relative 'menu/messages'
5
6
  require_relative 'menu/version'
6
7
 
7
8
  require 'pastel'
@@ -10,16 +11,22 @@ module Micro
10
11
  module Menu
11
12
  class Error < StandardError; end
12
13
 
13
- def self.configurations
14
- Configurations
15
- end
14
+ class << self
15
+ def configurations
16
+ Configurations
17
+ end
16
18
 
17
- def self.icons
18
- Icons
19
- end
19
+ def icons
20
+ Icons
21
+ end
22
+
23
+ def colors
24
+ @colors ||= Pastel.new
25
+ end
20
26
 
21
- def self.colors
22
- @colors ||= Pastel.new
27
+ def messages
28
+ Messages
29
+ end
23
30
  end
24
31
  end
25
32
  end
data/u-menu.gemspec CHANGED
@@ -31,8 +31,8 @@ Gem::Specification.new do |spec|
31
31
 
32
32
  # Uncomment to register a new dependency of your gem
33
33
  # spec.add_dependency "example-gem", "~> 1.0"
34
- spec.add_dependency 'pastel'
35
- spec.add_dependency 'tty-prompt'
34
+ spec.add_dependency 'pastel', '~> 0.8.0'
35
+ spec.add_dependency 'tty-prompt', '~> 0.23.1'
36
36
 
37
37
  # For more information and examples about making a new gem, check out our
38
38
  # guide at: https://bundler.io/guides/creating_gem.html
metadata CHANGED
@@ -1,43 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: u-menu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Vinciguerra
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-05-18 00:00:00.000000000 Z
11
+ date: 2023-05-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pastel
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: 0.8.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: 0.8.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: tty-prompt
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: 0.23.1
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: 0.23.1
41
41
  description: u-menu is a simple command pallet for terminal to increase productivity,
42
42
  keeping what you need closer
43
43
  email:
@@ -60,6 +60,7 @@ files:
60
60
  - lib/micro/menu.rb
61
61
  - lib/micro/menu/configurations.rb
62
62
  - lib/micro/menu/icons.rb
63
+ - lib/micro/menu/messages.rb
63
64
  - lib/micro/menu/version.rb
64
65
  - lib/u-menu.rb
65
66
  - u-menu.gemspec