handy_toolbox 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +13 -5
- data/bin/example +52 -0
- data/fixtures/rakes.txt +38 -0
- data/lib/handy_toolbox/app.rb +9 -18
- data/lib/handy_toolbox/screen.rb +18 -0
- data/lib/handy_toolbox/ui.rb +6 -0
- data/lib/handy_toolbox/version.rb +1 -1
- data/promo/1.png +0 -0
- data/promo/2.png +0 -0
- data/promo/3.png +0 -0
- metadata +4 -2
- data/promo/4.png +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1339da7be846b9dc3bce036dbcc4bd9338480709
|
4
|
+
data.tar.gz: 3dc2c7c12dacb1468e2e142f466dba1543f75c0e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7cf4d3cae1a4daaed0b2b3e3c029bcb458ea8b76fa229535b522072aff75470de6bcc8d8322b892db7973e3b846a4c62b5b82df3960e1c590d8d05797bb4e75b
|
7
|
+
data.tar.gz: e71a860c3bbceb136a0a8e8be99caffb75ef04809b9c67d300ec8aa44f348ce3e921c11a2afef20c8fe779d8ff8355d036a0ec0ac4c9329a7c664cb0fbf76dd8
|
data/CHANGELOG.md
ADDED
data/README.md
CHANGED
@@ -7,12 +7,14 @@ HandyToolbox is a text based user interface that will help you with every day ta
|
|
7
7
|
|
8
8
|
Gem was built for the Rails apps in mind but can be used standalone as well and not only for Ruby related stuff.
|
9
9
|
|
10
|
+
View [changelog](CHANGELOG.md).
|
11
|
+
|
10
12
|
## Installation
|
11
13
|
|
12
14
|
Add this line to your application's Gemfile:
|
13
15
|
|
14
16
|
```ruby
|
15
|
-
gem 'handy_toolbox'
|
17
|
+
gem 'handy_toolbox', require: false
|
16
18
|
```
|
17
19
|
|
18
20
|
And then execute:
|
@@ -41,6 +43,14 @@ app = App.new(title: 'Project name')
|
|
41
43
|
app.run
|
42
44
|
```
|
43
45
|
|
46
|
+
If you want to use your default terminal colors you can pass extra option to app:
|
47
|
+
|
48
|
+
```ruby
|
49
|
+
app = App.new(
|
50
|
+
default_colors: true # default is false
|
51
|
+
)
|
52
|
+
```
|
53
|
+
|
44
54
|
### Defining your tasks
|
45
55
|
|
46
56
|
Other example [here](EXAMPLE.md).
|
@@ -178,11 +188,9 @@ home / end - go to first/last item
|
|
178
188
|
|
179
189
|
![Main menu](promo/1.png?raw=true)
|
180
190
|
|
181
|
-
![
|
182
|
-
|
183
|
-
![Nested menu with loader not executed yet](promo/3.png?raw=true)
|
191
|
+
![Simple tasks](promo/2.png?raw=true)
|
184
192
|
|
185
|
-
![
|
193
|
+
![Long tasks](promo/3.png?raw=true)
|
186
194
|
|
187
195
|
## TODO
|
188
196
|
|
data/bin/example
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "handy_toolbox"
|
5
|
+
include HandyToolbox
|
6
|
+
|
7
|
+
|
8
|
+
class RakeLoader < Loader
|
9
|
+
def on_load(node)
|
10
|
+
data = IO.read('fixtures/rakes.txt')
|
11
|
+
data.strip.split("\n").each do |rake|
|
12
|
+
name, desc = rake.split("#")
|
13
|
+
node.tool name.strip, desc: desc.strip
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class RailsDatabasePlugin < Plugin
|
19
|
+
def on_attach(node)
|
20
|
+
node.menu 'Database' do |db|
|
21
|
+
db.tool 'rails db:migrate', name: 'Migrate database'
|
22
|
+
db.tool 'rails db:test:prepare', name: 'Prepare test database'
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
branch = Cmd.exec('git branch').match(/^\* (?<name>.+)$/)[:name]
|
29
|
+
app = App.new(
|
30
|
+
title: "My project name (on #{branch})"#,
|
31
|
+
# default_colors: true
|
32
|
+
)
|
33
|
+
|
34
|
+
app.menu 'Quick' do |quick|
|
35
|
+
quick.menu 'Some'
|
36
|
+
quick.tool 'ls -la', desc: 'Lists current directory'
|
37
|
+
end
|
38
|
+
|
39
|
+
app.menu 'Rails' do |rails|
|
40
|
+
rails.plugin RailsDatabasePlugin
|
41
|
+
rails.menu_loader 'Rake', RakeLoader
|
42
|
+
rails.menu 'Assets' do |assets|
|
43
|
+
assets.tool 'rake assets:precompile', desc: 'Precompile all the assets'
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
app.menu 'Deployment' do |deploy|
|
48
|
+
deploy.tool 'cap staging deploy', name: 'Deploy to staging'
|
49
|
+
deploy.tool 'cap production deploy', name: 'Deploy to production'
|
50
|
+
end
|
51
|
+
|
52
|
+
app.run
|
data/fixtures/rakes.txt
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
rake about # List versions of all Rails frameworks and the environment
|
2
|
+
rake app:template # Applies the template supplied by LOCATION=(/path/to/template) or URL
|
3
|
+
rake app:update # Update configs and some other initially generated files (or use just update:configs or update:bin)
|
4
|
+
rake assets:clean[keep] # Remove old compiled assets
|
5
|
+
rake assets:clobber # Remove compiled assets
|
6
|
+
rake assets:environment # Load asset compile environment
|
7
|
+
rake assets:precompile # Compile all the assets named in config.assets.precompile
|
8
|
+
rake cache_digests:dependencies # Lookup first-level dependencies for TEMPLATE (like messages/show or comments/_comment.html)
|
9
|
+
rake cache_digests:nested_dependencies # Lookup nested dependencies for TEMPLATE (like messages/show or comments/_comment.html)
|
10
|
+
rake db:create # Creates the database from DATABASE_URL or config/database.yml for the current RAILS_ENV (use db:create:all to create all databases in the config). Without RAILS_ENV or when RAILS_ENV is development, it defaults to creating the development and test databases
|
11
|
+
rake db:drop # Drops the database from DATABASE_URL or config/database.yml for the current RAILS_ENV (use db:drop:all to drop all databases in the config). Without RAILS_ENV or when RAILS_ENV is development, it defaults to dropping the development and test databases
|
12
|
+
rake db:environment:set # Set the environment value for the database
|
13
|
+
rake db:fixtures:load # Loads fixtures into the current environment's database
|
14
|
+
rake db:migrate # Migrate the database (options: VERSION=x, VERBOSE=false, SCOPE=blog)
|
15
|
+
rake db:migrate:status # Display status of migrations
|
16
|
+
rake db:rollback # Rolls the schema back to the previous version (specify steps w/ STEP=n)
|
17
|
+
rake db:schema:cache:clear # Clears a db/schema_cache.dump file
|
18
|
+
rake db:schema:cache:dump # Creates a db/schema_cache.dump file
|
19
|
+
rake db:schema:dump # Creates a db/schema.rb file that is portable against any DB supported by Active Record
|
20
|
+
rake db:schema:load # Loads a schema.rb file into the database
|
21
|
+
rake db:seed # Loads the seed data from db/seeds.rb
|
22
|
+
rake db:setup # Creates the database, loads the schema, and initializes with the seed data (use db:reset to also drop the database first)
|
23
|
+
rake db:structure:dump # Dumps the database structure to db/structure.sql
|
24
|
+
rake db:structure:load # Recreates the databases from the structure.sql file
|
25
|
+
rake db:version # Retrieves the current schema version number
|
26
|
+
rake dev:cache # Toggle development mode caching on/off
|
27
|
+
rake initializers # Print out all defined initializers in the order they are invoked by Rails
|
28
|
+
rake log:clear # Truncates all/specified *.log files in log/ to zero bytes (specify which logs with LOGS=test,development)
|
29
|
+
rake middleware # Prints out your Rack middleware stack
|
30
|
+
rake notes # Enumerate all annotations (use notes:optimize, :fixme, :todo for focus)
|
31
|
+
rake notes:custom # Enumerate a custom annotation, specify with ANNOTATION=CUSTOM
|
32
|
+
rake restart # Restart app by touching tmp/restart.txt
|
33
|
+
rake routes # Print out all defined routes in match order, with names
|
34
|
+
rake secret # Generate a cryptographically secure secret key (this is typically used to generate a secret for cookie sessions)
|
35
|
+
rake stats # Report code statistics (KLOCs, etc) from the application or engine
|
36
|
+
rake time:zones[country_or_offset] # List all time zones, list by two-letter country code (`rails time:zones[US]`), or list by UTC offset (`rails time:zones[-8]`)
|
37
|
+
rake tmp:clear # Clear cache and socket files from tmp/ (narrow w/ tmp:cache:clear, tmp:sockets:clear)
|
38
|
+
rake tmp:create # Creates tmp directories for cache, sockets, and pids
|
data/lib/handy_toolbox/app.rb
CHANGED
@@ -3,11 +3,11 @@ module HandyToolbox
|
|
3
3
|
class App
|
4
4
|
attr_reader :title
|
5
5
|
|
6
|
-
def initialize(title: "Tools")
|
6
|
+
def initialize(title: "Tools", default_colors: false)
|
7
7
|
@title = title
|
8
8
|
@loop = true
|
9
9
|
@builder = Menu.new(nil, nil)
|
10
|
-
@screen = Screen.new
|
10
|
+
@screen = Screen.new(default_colors: default_colors)
|
11
11
|
@navigator = Navigator.new
|
12
12
|
@tool_runner = ToolRunner.new
|
13
13
|
@positions = {}
|
@@ -21,7 +21,7 @@ module HandyToolbox
|
|
21
21
|
|
22
22
|
while @loop
|
23
23
|
screen.draw do
|
24
|
-
|
24
|
+
screen.header(title)
|
25
25
|
draw_tools
|
26
26
|
end
|
27
27
|
handle_input
|
@@ -94,17 +94,8 @@ module HandyToolbox
|
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
97
|
-
def draw_title
|
98
|
-
horizontal_line = "-" * (title.size + 4)
|
99
|
-
padded_title = "| #{title} |"
|
100
|
-
|
101
|
-
screen.text_at(0, 0, horizontal_line)
|
102
|
-
screen.text_at(0, 1, padded_title)
|
103
|
-
screen.text_at(0, 2, horizontal_line)
|
104
|
-
end
|
105
|
-
|
106
97
|
def draw_tools
|
107
|
-
y =
|
98
|
+
y = 2
|
108
99
|
longest = find_longest_child_name
|
109
100
|
@positions = {}
|
110
101
|
current.children.each_with_index do |child|
|
@@ -119,14 +110,14 @@ module HandyToolbox
|
|
119
110
|
if is_multiline
|
120
111
|
Ui.dim do
|
121
112
|
text = format_desc(str[1])
|
122
|
-
screen.text_at(
|
113
|
+
screen.text_at(1, y + 1, text)
|
123
114
|
end
|
124
115
|
text = format_child_name(child.icon, str[0], longest)
|
125
|
-
screen.text_at(
|
116
|
+
screen.text_at(1, y + 2, text)
|
126
117
|
@positions[child.id] = y + 2
|
127
118
|
else
|
128
119
|
text = format_child_name(child.icon, str, longest)
|
129
|
-
screen.text_at(
|
120
|
+
screen.text_at(1, y, text)
|
130
121
|
@positions[child.id] = y
|
131
122
|
end
|
132
123
|
end
|
@@ -141,11 +132,11 @@ module HandyToolbox
|
|
141
132
|
end
|
142
133
|
|
143
134
|
def format_desc(str)
|
144
|
-
"
|
135
|
+
" # #{str}"
|
145
136
|
end
|
146
137
|
|
147
138
|
def format_child_name(icon, name, max_len)
|
148
|
-
"
|
139
|
+
" #{icon}#{name.ljust(max_len, ' ')} "
|
149
140
|
end
|
150
141
|
|
151
142
|
def find_longest_child_name
|
data/lib/handy_toolbox/screen.rb
CHANGED
@@ -3,12 +3,18 @@ require 'curses'
|
|
3
3
|
module HandyToolbox
|
4
4
|
|
5
5
|
class Screen
|
6
|
+
SPACE = ' '.freeze
|
6
7
|
|
7
8
|
attr_reader :scroll
|
8
9
|
|
10
|
+
def initialize(default_colors: false)
|
11
|
+
@default_colors = default_colors
|
12
|
+
end
|
13
|
+
|
9
14
|
def init
|
10
15
|
Curses.init_screen
|
11
16
|
Curses.start_color
|
17
|
+
Curses.use_default_colors if @default_colors
|
12
18
|
Ui.hide_cursor
|
13
19
|
Curses.cbreak
|
14
20
|
Curses.crmode
|
@@ -30,8 +36,20 @@ module HandyToolbox
|
|
30
36
|
Curses.refresh
|
31
37
|
end
|
32
38
|
|
39
|
+
def header(title)
|
40
|
+
title = " #{title}"[0, Curses.cols - 1]
|
41
|
+
title = title.ljust(Curses.cols, SPACE)
|
42
|
+
|
43
|
+
Ui.reverse do
|
44
|
+
if scroll.fits_into_pane?(-scroll.top)
|
45
|
+
Ui.text_at(0, -scroll.top, title)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
33
50
|
def text_at(x, y, str)
|
34
51
|
if scroll.fits_into_pane?(y)
|
52
|
+
str = str[0, Curses.cols - x - 1]
|
35
53
|
Ui.text_at(x, y - scroll.top, str)
|
36
54
|
end
|
37
55
|
@max_y = y if @max_y < y
|
data/lib/handy_toolbox/ui.rb
CHANGED
data/promo/1.png
CHANGED
Binary file
|
data/promo/2.png
CHANGED
Binary file
|
data/promo/3.png
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: handy_toolbox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bartłomiej Wójtowicz
|
@@ -65,13 +65,16 @@ files:
|
|
65
65
|
- ".gitignore"
|
66
66
|
- ".ruby-gemset"
|
67
67
|
- ".ruby-version"
|
68
|
+
- CHANGELOG.md
|
68
69
|
- EXAMPLE.md
|
69
70
|
- Gemfile
|
70
71
|
- LICENSE.txt
|
71
72
|
- README.md
|
72
73
|
- Rakefile
|
73
74
|
- bin/console
|
75
|
+
- bin/example
|
74
76
|
- bin/setup
|
77
|
+
- fixtures/rakes.txt
|
75
78
|
- handy_toolbox.gemspec
|
76
79
|
- lib/handy_toolbox.rb
|
77
80
|
- lib/handy_toolbox/app.rb
|
@@ -94,7 +97,6 @@ files:
|
|
94
97
|
- promo/1.png
|
95
98
|
- promo/2.png
|
96
99
|
- promo/3.png
|
97
|
-
- promo/4.png
|
98
100
|
homepage: https://github.com/qbart/handy_toolbox
|
99
101
|
licenses:
|
100
102
|
- MIT
|
data/promo/4.png
DELETED
Binary file
|