shelldon-essentials 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/essentials.rb +67 -0
- data/lib/shelldon-essentials/version.rb +3 -0
- data/lib/shelldon-essentials.rb +2 -0
- data/lib/table-help-config.rb +49 -0
- metadata +119 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d8da8be39172d6d60035aa783800b1ae8750096a
|
4
|
+
data.tar.gz: 6db7580bbc30be61bfd04de81927fb4996ffa244
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d9eb94e1fa6ce1adc9426a4cb99996b21e418d3e49328aef1404671dc66ad9bfd690f58af40c8dfa7ac974faeccd48ced89568ea672e3299d7e150214fa00b4c
|
7
|
+
data.tar.gz: 2d03720af53833b3f52bd27da8c24bfc7370b3a7644a385c0f084cb54430836b781d0bb9ec0cec2dbf6c2644fd05eeb74efaa5b5afa2e237abf58387f70e74a2
|
data/lib/essentials.rb
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
Shelldon.module :essentials do
|
2
|
+
# Opts
|
3
|
+
|
4
|
+
# Config
|
5
|
+
config do
|
6
|
+
param :debug_mode do
|
7
|
+
type :boolean
|
8
|
+
default false
|
9
|
+
opt 'd'
|
10
|
+
end
|
11
|
+
|
12
|
+
param :'-o' do
|
13
|
+
type :string
|
14
|
+
default 'emacs'
|
15
|
+
adjust { |s| s.to_s.downcase.strip.gsub('vim', 'vi') }
|
16
|
+
validate do |s|
|
17
|
+
return false unless s == 'emacs' || s == 'vi'
|
18
|
+
if s == 'emacs'
|
19
|
+
Readline.emacs_editing_mode; true
|
20
|
+
else
|
21
|
+
Readline.vi_editing_mode; true
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
# Command Missing
|
28
|
+
command_missing do
|
29
|
+
action { |cmd| puts "No such command \"#{cmd}\"" }
|
30
|
+
end
|
31
|
+
|
32
|
+
# Commands
|
33
|
+
command :help do
|
34
|
+
action { |args| pp command_list.help(args) }
|
35
|
+
help 'Show help. Optionally specify specific command for more information.'
|
36
|
+
usage 'help [cmd]'
|
37
|
+
examples ['help', 'help quit']
|
38
|
+
end
|
39
|
+
|
40
|
+
command :config do
|
41
|
+
help 'Show the configuration of the current session.'
|
42
|
+
usage 'config'
|
43
|
+
action do |args|
|
44
|
+
if args.empty?
|
45
|
+
pp config.to_a
|
46
|
+
else
|
47
|
+
param = config.find(args.to_sym)
|
48
|
+
puts "#{param.name}: #{param.val}"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
subcommand :save do
|
53
|
+
help 'Save your current configuration'
|
54
|
+
usage 'config save'
|
55
|
+
action { config.save }
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
command :set do
|
60
|
+
help 'Set a configuration option for the remainder of the session.'
|
61
|
+
|
62
|
+
action do |args|
|
63
|
+
tokens = args.split(' ')
|
64
|
+
config[tokens[0].to_sym] = tokens[1]
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'tty'
|
2
|
+
|
3
|
+
class ShelldonTable
|
4
|
+
def self.print(header: nil, rows:)
|
5
|
+
puts TTY::Table.new(header: header, rows: rows).render(
|
6
|
+
:unicode, padding: [0, 1, 0, 1]
|
7
|
+
)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
Shelldon.module :table_help_config do
|
12
|
+
# Commands
|
13
|
+
command :help do
|
14
|
+
action do |args|
|
15
|
+
if args.empty?
|
16
|
+
header = ["Name", "Aliases", "Help"]
|
17
|
+
else
|
18
|
+
header = ["Name", "Help", "Usage", "Examples"]
|
19
|
+
end
|
20
|
+
ShelldonTable.print(
|
21
|
+
header: header,
|
22
|
+
rows: command_list.help(args))
|
23
|
+
end
|
24
|
+
help 'Show help. Optionally specify specific command for more information.'
|
25
|
+
usage 'help [cmd]'
|
26
|
+
examples ['help', 'help quit']
|
27
|
+
end
|
28
|
+
|
29
|
+
command :config do
|
30
|
+
help 'Show the configuration of the current session.'
|
31
|
+
usage 'config'
|
32
|
+
action do |args|
|
33
|
+
if args.empty?
|
34
|
+
ShelldonTable.print(
|
35
|
+
header: ["Command", "Value", "Flag"],
|
36
|
+
rows: config.to_a)
|
37
|
+
else
|
38
|
+
param = config.find(args.to_sym)
|
39
|
+
puts "#{param.name}: #{param.val}"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
subcommand :save do
|
44
|
+
help 'Save your current configuration'
|
45
|
+
usage 'config save'
|
46
|
+
action { config.save }
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
metadata
ADDED
@@ -0,0 +1,119 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: shelldon-essentials
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Wesley Boynton
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-09-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: shelldon
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.0.7
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.0.7
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: tty
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.11'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.11'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rubocop
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '10.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '10.0'
|
83
|
+
description:
|
84
|
+
email:
|
85
|
+
- wes@boynton.io
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- lib/essentials.rb
|
91
|
+
- lib/shelldon-essentials.rb
|
92
|
+
- lib/shelldon-essentials/version.rb
|
93
|
+
- lib/table-help-config.rb
|
94
|
+
homepage: http://www.shelldon.io
|
95
|
+
licenses:
|
96
|
+
- MIT
|
97
|
+
metadata: {}
|
98
|
+
post_install_message:
|
99
|
+
rdoc_options: []
|
100
|
+
require_paths:
|
101
|
+
- lib
|
102
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
112
|
+
requirements: []
|
113
|
+
rubyforge_project:
|
114
|
+
rubygems_version: 2.4.5.1
|
115
|
+
signing_key:
|
116
|
+
specification_version: 4
|
117
|
+
summary: A small assortment of commands and params to kick-start a basic Shelldon
|
118
|
+
app.
|
119
|
+
test_files: []
|