simple_commander 0.1.0 → 0.3.0
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 +4 -4
- data/.byebug_history +49 -0
- data/History.rdoc +7 -0
- data/README.md +5 -1
- data/bin/config.yml +2 -0
- data/bin/simple_commander +43 -4
- data/config.yml +4 -0
- data/coverage/.last_run.json +1 -1
- data/coverage/.resultset.json +175 -166
- data/ember_c +4 -6
- data/lib/simple_commander/cli.rb +60 -0
- data/lib/simple_commander/command.rb +21 -0
- data/lib/simple_commander/config.yml +2 -0
- data/lib/simple_commander/help_formatters/terminal.rb +1 -0
- data/lib/simple_commander/help_formatters/terminal/command_help.erb +2 -2
- data/lib/simple_commander/help_formatters/terminal/help.erb +1 -1
- data/lib/simple_commander/version.rb +1 -1
- data/logo.png +0 -0
- data/simple_commander.gemspec +1 -1
- data/spec/cli_spec.rb +67 -0
- data/spec/mock/config_without_path.yml +1 -0
- data/spec/spec_helper.rb +4 -4
- data/templates/bin.erb +7 -0
- data/templates/lib.erb +1 -0
- data/templates/version.erb +3 -0
- data/test.rb +17 -19
- data/test2.rb +8 -0
- data/todo.yml +8 -7
- metadata +15 -3
data/ember_c
CHANGED
@@ -2,22 +2,20 @@
|
|
2
2
|
$LOAD_PATH.unshift File.expand_path './lib'
|
3
3
|
|
4
4
|
require 'simple_commander/import'
|
5
|
-
require './helpers/http_helper'
|
6
5
|
|
7
6
|
program :name, 'ember-c'
|
8
7
|
program :version, '0.0.1'
|
9
8
|
program :description, 'implementing ember with modified commander'
|
10
|
-
helpers 'IO'
|
9
|
+
helpers 'IO'
|
11
10
|
|
12
11
|
command :new do
|
13
|
-
syntax
|
14
|
-
|
15
|
-
|
12
|
+
syntax 'ember-c new <name>'
|
13
|
+
description 'Create a new ember project'
|
14
|
+
option '--name STRING', String, 'changing stuff'
|
16
15
|
action do |args, options|
|
17
16
|
run_cmd(File.expand_path './') do
|
18
17
|
say `ls`
|
19
18
|
end
|
20
|
-
http_get
|
21
19
|
end
|
22
20
|
end
|
23
21
|
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'simple_commander/helpers/io'
|
3
|
+
require 'byebug'
|
4
|
+
|
5
|
+
module SimpleCommander
|
6
|
+
class CLI
|
7
|
+
include IO_helper
|
8
|
+
DEFAULT_PATH = "#{File.dirname(__FILE__)}/config.yml"
|
9
|
+
attr_accessor :config_file
|
10
|
+
|
11
|
+
class UndefinedSCPath < StandardError
|
12
|
+
def initialize
|
13
|
+
msg = <<-END
|
14
|
+
You need to set a path to commander
|
15
|
+
use simple_commander init <path> or cd to
|
16
|
+
the folder you want and just simple_commander init
|
17
|
+
END
|
18
|
+
super(msg)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def initialize(path=DEFAULT_PATH)
|
23
|
+
@config_file = path
|
24
|
+
end
|
25
|
+
|
26
|
+
def init(path='./')
|
27
|
+
if path
|
28
|
+
local_path = File.expand_path(path)
|
29
|
+
else
|
30
|
+
local_path = File.expand_path('./')
|
31
|
+
end
|
32
|
+
|
33
|
+
yml = { path: local_path }.to_yaml
|
34
|
+
File.open(@config_file, 'w+'){|f| f.write(yml)}
|
35
|
+
end
|
36
|
+
|
37
|
+
def show_config
|
38
|
+
say YAML.load_file(@config_file)
|
39
|
+
end
|
40
|
+
|
41
|
+
def new(*args)
|
42
|
+
sc_path = YAML.load_file(@config_file)[:path]
|
43
|
+
raise UndefinedSCPath if !sc_path
|
44
|
+
s_path = "#{sc_path}/#{args[0]}"
|
45
|
+
raise StandardError "program #{args[0]} already exists!" if File.directory?(s_path)
|
46
|
+
@program_name = args[0]
|
47
|
+
mkdir s_path
|
48
|
+
mkdir "#{s_path}/bin"
|
49
|
+
mkdir "#{s_path}/spec"
|
50
|
+
mkdir "#{s_path}/lib"
|
51
|
+
mkdir "#{s_path}/lib/#{@program_name}"
|
52
|
+
template './templates/lib.erb',
|
53
|
+
"#{s_path}/lib/#{@program_name}.rb"
|
54
|
+
template './templates/version.erb',
|
55
|
+
"#{s_path}/lib/#{@program_name}/version.rb"
|
56
|
+
template './templates/bin.erb',
|
57
|
+
"#{s_path}/bin/#{@program_name}"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -5,6 +5,27 @@ module SimpleCommander
|
|
5
5
|
attr_accessor :name, :examples, :syntax, :description, :super_self
|
6
6
|
attr_accessor :summary, :proxy_options, :options
|
7
7
|
|
8
|
+
##
|
9
|
+
# set syntax
|
10
|
+
|
11
|
+
def syntax(val)
|
12
|
+
@syntax = val
|
13
|
+
end
|
14
|
+
|
15
|
+
##
|
16
|
+
# summany
|
17
|
+
|
18
|
+
def summary(val)
|
19
|
+
@summary = val
|
20
|
+
end
|
21
|
+
|
22
|
+
##
|
23
|
+
# description
|
24
|
+
|
25
|
+
def description(val)
|
26
|
+
@description = val
|
27
|
+
end
|
28
|
+
|
8
29
|
##
|
9
30
|
# Options struct.
|
10
31
|
|
@@ -12,7 +12,7 @@
|
|
12
12
|
|
13
13
|
<%= $terminal.color "DESCRIPTION", :bold %>:
|
14
14
|
|
15
|
-
<%=
|
15
|
+
<%= SimpleCommander::HelpFormatter.indent 4, (@description || @summary || 'No description.') -%>
|
16
16
|
|
17
17
|
<% unless @examples.empty? -%>
|
18
18
|
|
@@ -29,7 +29,7 @@
|
|
29
29
|
<% for option in @options -%>
|
30
30
|
|
31
31
|
<%= option[:switches].join ', ' %>
|
32
|
-
<%=
|
32
|
+
<%= SimpleCommander::HelpFormatter.indent 8, option[:description] %>
|
33
33
|
<% end -%>
|
34
34
|
<% end -%>
|
35
35
|
|
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
<%= $terminal.color "DESCRIPTION", :bold %>:
|
6
6
|
|
7
|
-
<%=
|
7
|
+
<%= SimpleCommander::HelpFormatter.indent 4, program(:description) %>
|
8
8
|
|
9
9
|
<%= $terminal.color "COMMANDS", :bold %>:
|
10
10
|
<% for name, command in @commands.sort -%>
|
data/logo.png
ADDED
Binary file
|
data/simple_commander.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
|
|
9
9
|
s.email = ['0000marcell@gmail.com']
|
10
10
|
s.license = 'MIT'
|
11
11
|
s.homepage = 'https://github.com/0000marcell/simple_commander'
|
12
|
-
s.summary = '
|
12
|
+
s.summary = 'Command line framework based on commander and inspired by GLI Thor and others...'
|
13
13
|
s.files = `git ls-files`.split("\n")
|
14
14
|
s.test_files = `git ls-files -- {test, spec, features}/*`.split("\n")
|
15
15
|
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
data/spec/cli_spec.rb
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'simple_commander/cli'
|
3
|
+
require 'byebug'
|
4
|
+
|
5
|
+
describe SimpleCommander::CLI do
|
6
|
+
CONFIG_FILE =
|
7
|
+
File.dirname(__FILE__) + '/mock/config.yml'
|
8
|
+
|
9
|
+
before :each do
|
10
|
+
mock_terminal
|
11
|
+
end
|
12
|
+
|
13
|
+
after :each do
|
14
|
+
if(File.file?(CONFIG_FILE))
|
15
|
+
FileUtils.rm(CONFIG_FILE)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe '#init' do
|
20
|
+
it 'writes the path in to a config file' do
|
21
|
+
cli = SimpleCommander::CLI.new(CONFIG_FILE)
|
22
|
+
cli.init
|
23
|
+
yml = YAML.load_file(CONFIG_FILE)
|
24
|
+
expect(yml[:path].empty?).to eq(false)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe '#show_config' do
|
29
|
+
it 'shows the config file info' do
|
30
|
+
cli = SimpleCommander::CLI.new(CONFIG_FILE)
|
31
|
+
cli.init
|
32
|
+
cli.show_config
|
33
|
+
expect(@output.string.empty?).to eq(false)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe '#new' do
|
38
|
+
it 'raise error create a new program without initializing the path' do
|
39
|
+
path = File.dirname(__FILE__) +
|
40
|
+
'/mock/config_without_path.yml'
|
41
|
+
cli = SimpleCommander::CLI.new(path)
|
42
|
+
expect do
|
43
|
+
cli.new('ex_program')
|
44
|
+
end.to raise_error(SimpleCommander::CLI::UndefinedSCPath)
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'raise error when creating program that already exists' do
|
48
|
+
path = File.dirname(__FILE__) +
|
49
|
+
'/mock'
|
50
|
+
cli = SimpleCommander::CLI.new
|
51
|
+
cli.init(path)
|
52
|
+
expect do
|
53
|
+
cli.new('test_program')
|
54
|
+
end.to raise_error(StandardError)
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'creates new folders for the program' do
|
58
|
+
path = File.dirname(__FILE__) +
|
59
|
+
'/mock'
|
60
|
+
cli = SimpleCommander::CLI.new
|
61
|
+
cli.init(path)
|
62
|
+
cli.new('ex_program')
|
63
|
+
expect(File.directory?('./spec/mock/ex_program')).to eq (true)
|
64
|
+
FileUtils.remove_dir('./spec/mock/ex_program')
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
:path:
|
data/spec/spec_helper.rb
CHANGED
@@ -2,11 +2,11 @@ require 'rubygems'
|
|
2
2
|
require 'stringio'
|
3
3
|
require 'simplecov'
|
4
4
|
require "codeclimate-test-reporter"
|
5
|
-
CodeClimate::TestReporter.start
|
5
|
+
#CodeClimate::TestReporter.start
|
6
6
|
|
7
|
-
SimpleCov.start do
|
8
|
-
|
9
|
-
end
|
7
|
+
#SimpleCov.start do
|
8
|
+
#add_filter '/spec/'
|
9
|
+
#end
|
10
10
|
|
11
11
|
|
12
12
|
|
data/templates/bin.erb
ADDED
data/templates/lib.erb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require '<%= @program_name %>/version'
|
data/test.rb
CHANGED
@@ -1,24 +1,22 @@
|
|
1
|
-
module
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
module Commander
|
2
|
+
class CLI
|
3
|
+
attr_accessor :path
|
4
|
+
class Fuck < StandardError
|
5
|
+
def initialize
|
6
|
+
super("this is a error")
|
7
|
+
end
|
8
|
+
end
|
6
9
|
|
10
|
+
def initialize
|
11
|
+
@path = 'marcell'
|
12
|
+
end
|
7
13
|
|
8
|
-
|
9
|
-
|
10
|
-
|
14
|
+
def self.error
|
15
|
+
raise Fuck
|
16
|
+
end
|
11
17
|
end
|
12
18
|
end
|
13
19
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
#fail InvalidCommandError, 'invalid command', caller if !defined? helper_name
|
18
|
-
|
19
|
-
doc = Document.new
|
20
|
-
doc.include_mixin
|
21
|
-
doc.testing
|
22
|
-
|
23
|
-
puts doc.methods.include? :testing
|
24
|
-
|
20
|
+
cli = Commander::CLI.new
|
21
|
+
cli.path = 'joao'
|
22
|
+
puts cli.path
|
data/test2.rb
ADDED
data/todo.yml
CHANGED
@@ -1,17 +1,13 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
make the helper search in the helpers folder of the project
|
4
|
-
raise exeption when the helper is undefined
|
5
|
-
write tests for the helpers method
|
6
|
-
implement helpers command
|
1
|
+
create init cli command that creates a folder for the scripts
|
2
|
+
identify if the name of the program is permited
|
7
3
|
create scommader cli which transform the script in an directory with helpers,
|
8
4
|
tests etc..
|
9
5
|
add ci
|
10
6
|
add codeclimate
|
11
7
|
add test coverage
|
8
|
+
solve rubocop problems
|
12
9
|
add logo to read and simple readme
|
13
10
|
add suport for helpers
|
14
|
-
make syntax, options ect.. actually methods instead of variables
|
15
11
|
make say accept a color hex
|
16
12
|
make possible to pass more than one action, and execute sequentially
|
17
13
|
|
@@ -21,6 +17,11 @@ learn about the implementation of the commander progress bar
|
|
21
17
|
figuring out the progress bar
|
22
18
|
|
23
19
|
done:
|
20
|
+
make syntax, options ect.. actually methods instead of variables
|
21
|
+
implement helpers command
|
22
|
+
write tests for the helpers method
|
23
|
+
write tests and add helper functionality to readme
|
24
|
+
write documentaion for hepers in the readme
|
24
25
|
learn how to use rubocop
|
25
26
|
change the name of the Commander module to SimpleCommander
|
26
27
|
add highline as a dependency on the gem
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_commander
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marcell Monteiro Cruz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-10-
|
11
|
+
date: 2016-10-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: highline
|
@@ -84,6 +84,7 @@ description:
|
|
84
84
|
email:
|
85
85
|
- 0000marcell@gmail.com
|
86
86
|
executables:
|
87
|
+
- config.yml
|
87
88
|
- simple_commander
|
88
89
|
extensions: []
|
89
90
|
extra_rdoc_files: []
|
@@ -99,7 +100,9 @@ files:
|
|
99
100
|
- Manifest
|
100
101
|
- README.md
|
101
102
|
- Rakefile
|
103
|
+
- bin/config.yml
|
102
104
|
- bin/simple_commander
|
105
|
+
- config.yml
|
103
106
|
- coverage/.last_run.json
|
104
107
|
- coverage/.resultset.json
|
105
108
|
- coverage/.resultset.json.lock
|
@@ -110,7 +113,9 @@ files:
|
|
110
113
|
- ideal_spec.rb
|
111
114
|
- lib/simple_commander.rb
|
112
115
|
- lib/simple_commander/blank.rb
|
116
|
+
- lib/simple_commander/cli.rb
|
113
117
|
- lib/simple_commander/command.rb
|
118
|
+
- lib/simple_commander/config.yml
|
114
119
|
- lib/simple_commander/configure.rb
|
115
120
|
- lib/simple_commander/core_ext.rb
|
116
121
|
- lib/simple_commander/core_ext/array.rb
|
@@ -132,7 +137,9 @@ files:
|
|
132
137
|
- lib/simple_commander/runner.rb
|
133
138
|
- lib/simple_commander/user_interaction.rb
|
134
139
|
- lib/simple_commander/version.rb
|
140
|
+
- logo.png
|
135
141
|
- simple_commander.gemspec
|
142
|
+
- spec/cli_spec.rb
|
136
143
|
- spec/command_spec.rb
|
137
144
|
- spec/configure_spec.rb
|
138
145
|
- spec/core_ext/array_spec.rb
|
@@ -140,10 +147,15 @@ files:
|
|
140
147
|
- spec/help_formatters/terminal_compact_spec.rb
|
141
148
|
- spec/help_formatters/terminal_spec.rb
|
142
149
|
- spec/methods_spec.rb
|
150
|
+
- spec/mock/config_without_path.yml
|
143
151
|
- spec/runner_spec.rb
|
144
152
|
- spec/spec_helper.rb
|
145
153
|
- spec/ui_spec.rb
|
154
|
+
- templates/bin.erb
|
155
|
+
- templates/lib.erb
|
156
|
+
- templates/version.erb
|
146
157
|
- test.rb
|
158
|
+
- test2.rb
|
147
159
|
- todo.yml
|
148
160
|
homepage: https://github.com/0000marcell/simple_commander
|
149
161
|
licenses:
|
@@ -168,5 +180,5 @@ rubyforge_project:
|
|
168
180
|
rubygems_version: 2.5.1
|
169
181
|
signing_key:
|
170
182
|
specification_version: 4
|
171
|
-
summary:
|
183
|
+
summary: Command line framework based on commander and inspired by GLI Thor and others...
|
172
184
|
test_files: []
|