shelldon 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/Gemfile +8 -0
- data/Gemfile.lock +43 -0
- data/LICENSE.txt +21 -0
- data/README.md +138 -0
- data/Rakefile +1 -0
- data/bin/shelldon +8 -0
- data/build_and_install.sh +3 -0
- data/lib/Exceptions/error_factory.rb +26 -0
- data/lib/cli.rb +19 -0
- data/lib/command/command.rb +134 -0
- data/lib/command/command_list.rb +72 -0
- data/lib/config/config.rb +85 -0
- data/lib/config/config_factory.rb +41 -0
- data/lib/config/param.rb +54 -0
- data/lib/config/param/boolean_param.rb +28 -0
- data/lib/config/param/number_param.rb +7 -0
- data/lib/config/param/string_param.rb +8 -0
- data/lib/config/param_factory.rb +75 -0
- data/lib/defaults/commands.rb +0 -0
- data/lib/dsl.rb +21 -0
- data/lib/file_management/config_file_manager.rb +34 -0
- data/lib/file_management/file_manager.rb +20 -0
- data/lib/file_management/history_file.rb +34 -0
- data/lib/file_management/yaml_manager.rb +16 -0
- data/lib/helpers/timer.rb +17 -0
- data/lib/opts/opt_factory.rb +30 -0
- data/lib/opts/opts.rb +13 -0
- data/lib/shell/shell.rb +167 -0
- data/lib/shell/shell_factory.rb +38 -0
- data/lib/shell/shell_index.rb +33 -0
- data/lib/shelldon.rb +26 -0
- data/lib/shelldon/version.rb +3 -0
- data/shelldon.gemspec +28 -0
- data/test_shell/Gemfile +3 -0
- data/test_shell/Gemfile.lock +20 -0
- data/test_shell/run.sh +3 -0
- data/test_shell/simple_shell.rb +106 -0
- data/test_shell/test_shell.rb +82 -0
- data/test_shell/useful_commands.rb +11 -0
- metadata +130 -0
@@ -0,0 +1,82 @@
|
|
1
|
+
require 'shelldon'
|
2
|
+
require 'pp'
|
3
|
+
Shelldon.shell do
|
4
|
+
opts { opt '--debug', '-d', :boolean }
|
5
|
+
|
6
|
+
config do
|
7
|
+
config_file '.shelldon_config'
|
8
|
+
param :debug_mode do
|
9
|
+
type :boolean
|
10
|
+
default false
|
11
|
+
opt 'd'
|
12
|
+
end
|
13
|
+
|
14
|
+
param :value do
|
15
|
+
type :string
|
16
|
+
default 'This is the default value!'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
command_missing do
|
21
|
+
action { |cmd| puts "No such command \"#{cmd}\"" }
|
22
|
+
end
|
23
|
+
|
24
|
+
command :arg do
|
25
|
+
help 'Show your args off!'
|
26
|
+
action { |args| puts args }
|
27
|
+
end
|
28
|
+
|
29
|
+
command :blah do
|
30
|
+
action { puts config[:value] }
|
31
|
+
subcommand :swag do
|
32
|
+
action { puts 'SWIGGITY SWAG!!!!' }
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
command :help do
|
37
|
+
action { |args| pp command_list.help(args) }
|
38
|
+
help 'Show help. Optionally specify specific command for more information.'
|
39
|
+
usage 'help [cmd]'
|
40
|
+
examples ['help', 'help quit']
|
41
|
+
end
|
42
|
+
|
43
|
+
command :config do
|
44
|
+
help 'Show the configuration of the current session.'
|
45
|
+
usage 'config'
|
46
|
+
action do |args|
|
47
|
+
if args.empty?
|
48
|
+
pp config.to_a
|
49
|
+
else
|
50
|
+
param = config.find(args.to_sym)
|
51
|
+
puts "#{param.name}: #{param.val}"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
subcommand :save do
|
56
|
+
help 'Save your current configuration'
|
57
|
+
usage 'config save'
|
58
|
+
action { config.save }
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
command :set do
|
63
|
+
help 'Set a configuration option for the remainder of the session.'
|
64
|
+
|
65
|
+
action do |args|
|
66
|
+
tokens = args.split(' ')
|
67
|
+
config[tokens[0].to_sym] = tokens[1]
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
shell do
|
72
|
+
prompt 'shelldon> '
|
73
|
+
home '~/.shelldon-test'
|
74
|
+
history true
|
75
|
+
history_file '.shelldon-history'
|
76
|
+
|
77
|
+
errors do
|
78
|
+
accept StandardError
|
79
|
+
accept(Interrupt) { puts '^C' }
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
Shelldon.shell do
|
2
|
+
command :toggle do
|
3
|
+
help 'Toggle a boolean configuration option.'
|
4
|
+
action do |cmd|
|
5
|
+
tokens = cmd.split(' ')
|
6
|
+
cfg = config[tokens[0].to_sym]
|
7
|
+
fail(StandardError) unless cfg.is_a?(BooleanParam)
|
8
|
+
config[tokens[0].to_sym].toggle
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
metadata
ADDED
@@ -0,0 +1,130 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: shelldon
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Wesley Boynton
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-12-13 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.10'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.10'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rubocop
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.33.0
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.33.0
|
55
|
+
description: Shelldon is an expressive DSL for build interactive command-line apps
|
56
|
+
(REPLs)with minimal effort. It supports all kinds of fun features, like config/history
|
57
|
+
management, error handling, subcommands, subshells, and more!
|
58
|
+
email:
|
59
|
+
- wes@boynton.io
|
60
|
+
executables:
|
61
|
+
- shelldon
|
62
|
+
extensions: []
|
63
|
+
extra_rdoc_files: []
|
64
|
+
files:
|
65
|
+
- "./Gemfile"
|
66
|
+
- "./Gemfile.lock"
|
67
|
+
- "./LICENSE.txt"
|
68
|
+
- "./README.md"
|
69
|
+
- "./Rakefile"
|
70
|
+
- "./bin/shelldon"
|
71
|
+
- "./build_and_install.sh"
|
72
|
+
- "./lib/Exceptions/error_factory.rb"
|
73
|
+
- "./lib/cli.rb"
|
74
|
+
- "./lib/command/command.rb"
|
75
|
+
- "./lib/command/command_list.rb"
|
76
|
+
- "./lib/config/config.rb"
|
77
|
+
- "./lib/config/config_factory.rb"
|
78
|
+
- "./lib/config/param.rb"
|
79
|
+
- "./lib/config/param/boolean_param.rb"
|
80
|
+
- "./lib/config/param/number_param.rb"
|
81
|
+
- "./lib/config/param/string_param.rb"
|
82
|
+
- "./lib/config/param_factory.rb"
|
83
|
+
- "./lib/defaults/commands.rb"
|
84
|
+
- "./lib/dsl.rb"
|
85
|
+
- "./lib/file_management/config_file_manager.rb"
|
86
|
+
- "./lib/file_management/file_manager.rb"
|
87
|
+
- "./lib/file_management/history_file.rb"
|
88
|
+
- "./lib/file_management/yaml_manager.rb"
|
89
|
+
- "./lib/helpers/timer.rb"
|
90
|
+
- "./lib/opts/opt_factory.rb"
|
91
|
+
- "./lib/opts/opts.rb"
|
92
|
+
- "./lib/shell/shell.rb"
|
93
|
+
- "./lib/shell/shell_factory.rb"
|
94
|
+
- "./lib/shell/shell_index.rb"
|
95
|
+
- "./lib/shelldon.rb"
|
96
|
+
- "./lib/shelldon/version.rb"
|
97
|
+
- "./shelldon.gemspec"
|
98
|
+
- "./test_shell/Gemfile"
|
99
|
+
- "./test_shell/Gemfile.lock"
|
100
|
+
- "./test_shell/run.sh"
|
101
|
+
- "./test_shell/simple_shell.rb"
|
102
|
+
- "./test_shell/test_shell.rb"
|
103
|
+
- "./test_shell/useful_commands.rb"
|
104
|
+
- bin/shelldon
|
105
|
+
homepage: https://github.com/wwboynton/shelldon
|
106
|
+
licenses:
|
107
|
+
- MIT
|
108
|
+
metadata: {}
|
109
|
+
post_install_message:
|
110
|
+
rdoc_options: []
|
111
|
+
require_paths:
|
112
|
+
- lib
|
113
|
+
- bin
|
114
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
124
|
+
requirements: []
|
125
|
+
rubyforge_project:
|
126
|
+
rubygems_version: 2.4.5
|
127
|
+
signing_key:
|
128
|
+
specification_version: 4
|
129
|
+
summary: An expressive DSL for building interactive command-line apps
|
130
|
+
test_files: []
|