command_lion 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/.yardopts +1 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +70 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/command_lion.gemspec +27 -0
- data/examples/debug.rb +5 -0
- data/examples/example.rb +31 -0
- data/examples/example2.rb +56 -0
- data/examples/example_rainbows.rb +21 -0
- data/examples/flipr.rb +27 -0
- data/examples/flipr2.rb +48 -0
- data/examples/flipr3.rb +31 -0
- data/examples/flipr4.rb +33 -0
- data/examples/hello_expanded.rb +33 -0
- data/examples/hello_multi.rb +32 -0
- data/examples/hello_world.rb +17 -0
- data/examples/key_value_example.rb +19 -0
- data/examples/numbers.txt +3 -0
- data/examples/plugin.rb +26 -0
- data/examples/read_file.rb +21 -0
- data/examples/read_stdin.rb +21 -0
- data/examples/readme.rb +35 -0
- data/examples/sample.rb +27 -0
- data/examples/simple_attr_example.rb +19 -0
- data/examples/simple_attrs_example.rb +20 -0
- data/examples/words.txt +3 -0
- data/lib/command_lion/app.rb +346 -0
- data/lib/command_lion/base.rb +112 -0
- data/lib/command_lion/command.rb +148 -0
- data/lib/command_lion/flags.rb +7 -0
- data/lib/command_lion/option.rb +3 -0
- data/lib/command_lion/raw.rb +31 -0
- data/lib/command_lion/version.rb +3 -0
- data/lib/command_lion.rb +11 -0
- metadata +127 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: cee05e4f0555f83fb7dffe36f7c28e6ca8603aa5
|
4
|
+
data.tar.gz: 6c3c462a11454e503033a4af744bec9132454b1f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: da7d776824f0b1ba28da9cbc1085662f7d3ef1d9b757bf47ae9cbb9722de1b2089000d4898ec4827f7fa9facb67ebc3d8efdf29b7ebaddb358fbae956c579c6b
|
7
|
+
data.tar.gz: 1743834b1f7b78e3e45c2fc282a588b6e234de7c2a8cffcb035758016af72a30c0f2412179ade2b1d050cb3789e968773a9d9685d099d5ad67dbbf176ac77c03
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/.yardopts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--no-private
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at kgruber1@emich.edu. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Kent Gruber
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
# 🦁 Command Lion
|
2
|
+
|
3
|
+
Command-line application framework.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
$ gem install command_lion
|
8
|
+
|
9
|
+
## Usage
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
require 'command_lion'
|
13
|
+
|
14
|
+
CommandLion::App.run do
|
15
|
+
|
16
|
+
name "Rainbow Hello"
|
17
|
+
version "1.0.0"
|
18
|
+
description "A typical, contrived example application."
|
19
|
+
|
20
|
+
command :hello do
|
21
|
+
description "A simple command to say hello!"
|
22
|
+
type :string
|
23
|
+
flag "hello"
|
24
|
+
default "world"
|
25
|
+
|
26
|
+
action do
|
27
|
+
puts "Hello #{argument}!"
|
28
|
+
end
|
29
|
+
|
30
|
+
option :rainbow do
|
31
|
+
description "STDOUT is much prettier with rainbows!"
|
32
|
+
flag "--rainbow"
|
33
|
+
|
34
|
+
action do
|
35
|
+
require 'lolize/auto'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
```
|
42
|
+
|
43
|
+
At the command-line:
|
44
|
+
|
45
|
+
```shell
|
46
|
+
> hello_rainbow
|
47
|
+
Rainbow Hello
|
48
|
+
|
49
|
+
VERSION
|
50
|
+
1.0.0
|
51
|
+
|
52
|
+
DESCRIPTION
|
53
|
+
A typical, contrived example application.
|
54
|
+
|
55
|
+
USAGE
|
56
|
+
examples/readme.rb [command] [arguments...] [options]
|
57
|
+
|
58
|
+
COMMANDS
|
59
|
+
hello A simple command to say hello!
|
60
|
+
--rainbow STDOUT is much prettier with rainbows!
|
61
|
+
>
|
62
|
+
```
|
63
|
+
|
64
|
+
## License
|
65
|
+
|
66
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
67
|
+
|
68
|
+
## Code of Conduct
|
69
|
+
|
70
|
+
Everyone interacting in the CommandLion project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/command_lion/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "command_lion"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "command_lion/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "command_lion"
|
8
|
+
spec.version = CommandLion::VERSION
|
9
|
+
spec.authors = ["Kent 'picat' Gruber"]
|
10
|
+
spec.email = ["kgruber1@emich.edu"]
|
11
|
+
|
12
|
+
spec.summary = %q{Command-line application framework.}
|
13
|
+
#spec.description = %q{TODO: Write a longer description or delete this line.}
|
14
|
+
spec.homepage = "https://github.com/picatz/command_lion"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
|
+
f.match(%r{^(test|spec|features)/})
|
19
|
+
end
|
20
|
+
spec.bindir = "exe"
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
+
spec.require_paths = ["lib"]
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.15"
|
25
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
27
|
+
end
|
data/examples/debug.rb
ADDED
data/examples/example.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
2
|
+
require 'command_lion'
|
3
|
+
require 'pry'
|
4
|
+
|
5
|
+
CommandLion::App.run do
|
6
|
+
|
7
|
+
name "Rainbow Hello"
|
8
|
+
version "1.0.0"
|
9
|
+
|
10
|
+
command :hello do
|
11
|
+
description "A simple option to say hello!"
|
12
|
+
|
13
|
+
type :string
|
14
|
+
flag "hello"
|
15
|
+
|
16
|
+
default "world"
|
17
|
+
|
18
|
+
action do
|
19
|
+
puts "Hello #{argument}!"
|
20
|
+
end
|
21
|
+
|
22
|
+
option :rainbow do
|
23
|
+
flag "--rainbow"
|
24
|
+
action do
|
25
|
+
require 'lolize/auto'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
@@ -0,0 +1,56 @@
|
|
1
|
+
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
2
|
+
require 'command_lion'
|
3
|
+
require 'pry'
|
4
|
+
|
5
|
+
CommandLion::App.run do
|
6
|
+
|
7
|
+
name "Hello World!"
|
8
|
+
version "1.0.0"
|
9
|
+
description "Your typical, contrived application example."
|
10
|
+
|
11
|
+
command :rainbow do
|
12
|
+
description "STDOUT looks so much better with rainbows."
|
13
|
+
flag "--rainbow"
|
14
|
+
action do
|
15
|
+
require "lolize/auto"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
command :hello do
|
20
|
+
description "A simple option to say hello!"
|
21
|
+
|
22
|
+
type :string
|
23
|
+
flag "hello"
|
24
|
+
|
25
|
+
default "world"
|
26
|
+
|
27
|
+
action do
|
28
|
+
puts "Hello #{argument}!"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
command :hello_multi do
|
33
|
+
description "A simple option to say hello to multiple people!"
|
34
|
+
|
35
|
+
type :strings
|
36
|
+
delimiter ","
|
37
|
+
|
38
|
+
flag "hellos"
|
39
|
+
|
40
|
+
default ["bob", "alice"]
|
41
|
+
|
42
|
+
action do
|
43
|
+
arguments.each do |argument|
|
44
|
+
next if argument == options[:ignore].argument
|
45
|
+
puts "Hello #{argument}!"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
option :ignore do
|
50
|
+
description "Optionally ignore one person."
|
51
|
+
flag "--ignore"
|
52
|
+
type :string
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
2
|
+
require 'command_lion'
|
3
|
+
require 'pry'
|
4
|
+
|
5
|
+
CommandLion::App.run do
|
6
|
+
|
7
|
+
name "Rainbow Hello"
|
8
|
+
version "1.0.0"
|
9
|
+
#rainbows
|
10
|
+
|
11
|
+
command "Say Hello" do
|
12
|
+
type :string
|
13
|
+
flag "hello"
|
14
|
+
default "world"
|
15
|
+
|
16
|
+
action do
|
17
|
+
puts "Hello #{argument}!"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
data/examples/flipr.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
2
|
+
require 'command_lion'
|
3
|
+
require 'pry'
|
4
|
+
|
5
|
+
|
6
|
+
CommandLion::App.run do
|
7
|
+
|
8
|
+
name "Flipr"
|
9
|
+
version "1.0.0"
|
10
|
+
description "Flipping tables in terminals made easy!"
|
11
|
+
|
12
|
+
command :flip do
|
13
|
+
description "Flip a table."
|
14
|
+
|
15
|
+
flips = ["[ ╯ '□']╯︵┻━┻)", "[ ╯ಠ益ಠ]╯彡┻━┻)", "[ ╯´・ω・]╯︵┸━┸)"]
|
16
|
+
|
17
|
+
flags do
|
18
|
+
short "-f"
|
19
|
+
long "--flip"
|
20
|
+
end
|
21
|
+
|
22
|
+
action do
|
23
|
+
puts flips.sample
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
data/examples/flipr2.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
2
|
+
require 'command_lion'
|
3
|
+
require 'pry'
|
4
|
+
|
5
|
+
def random_sleep
|
6
|
+
sleep (0..5).to_a.sample
|
7
|
+
end
|
8
|
+
|
9
|
+
def synchronize(&block)
|
10
|
+
@semaphore ||= Mutex.new
|
11
|
+
@semaphore.synchronize do
|
12
|
+
block.call
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
CommandLion::App.run do
|
17
|
+
|
18
|
+
name "Flipr"
|
19
|
+
version "1.0.0"
|
20
|
+
description "Flipping tables in terminals made easy!"
|
21
|
+
|
22
|
+
command :flip do
|
23
|
+
threaded
|
24
|
+
description "Flip a table."
|
25
|
+
flag "--flip"
|
26
|
+
flips = ["[ ╯ '□']╯︵┻━┻)", "[ ╯ಠ益ಠ]╯彡┻━┻)", "[ ╯´・ω・]╯︵┸━┸)"]
|
27
|
+
action do
|
28
|
+
10.times do
|
29
|
+
random_sleep
|
30
|
+
synchronize { puts flips.sample }
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
command :put do
|
36
|
+
threaded
|
37
|
+
description "Put a table."
|
38
|
+
flag "--put"
|
39
|
+
puts = ["┬──┬ノ['-' ノ ]", "┬──┬ノ[・ω・ ノ ]", "┬──┬ノ['~' ノ ]"]
|
40
|
+
action do
|
41
|
+
10.times do
|
42
|
+
random_sleep
|
43
|
+
synchronize { puts puts.sample }
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
data/examples/flipr3.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
2
|
+
require 'command_lion'
|
3
|
+
require 'pry'
|
4
|
+
|
5
|
+
CommandLion::App.run do
|
6
|
+
|
7
|
+
name "Flipr"
|
8
|
+
version "1.0.0"
|
9
|
+
description "Flipping tables in terminals made easy!"
|
10
|
+
|
11
|
+
command :flip do
|
12
|
+
description "Flip a table."
|
13
|
+
flag "--flip"
|
14
|
+
|
15
|
+
flips = ["[ ╯ '□']╯︵┻━┻)", "[ ╯ಠ益ಠ]╯彡┻━┻)", "[ ╯´・ω・]╯︵┸━┸)"]
|
16
|
+
|
17
|
+
action do
|
18
|
+
options[:count].argument.times do
|
19
|
+
puts flips.sample
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
option :count do
|
24
|
+
default 3
|
25
|
+
description "Specify the number of flips ( default: #{default} )"
|
26
|
+
type :integer
|
27
|
+
flag "--count"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
data/examples/flipr4.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
2
|
+
require 'command_lion'
|
3
|
+
require 'pry'
|
4
|
+
|
5
|
+
CommandLion::App.run do
|
6
|
+
|
7
|
+
name "Flipr"
|
8
|
+
version "1.0.0"
|
9
|
+
description "Flipping tables in terminals made easy!"
|
10
|
+
|
11
|
+
command :flip do
|
12
|
+
description "Flip a table."
|
13
|
+
flag "--flip"
|
14
|
+
|
15
|
+
flips = ["[ ╯ '□']╯︵┻━┻)", "[ ╯ಠ益ಠ]╯彡┻━┻)", "[ ╯´・ω・]╯︵┸━┸)"]
|
16
|
+
|
17
|
+
action do
|
18
|
+
options[:count].arguments do |argument|
|
19
|
+
argument.times do
|
20
|
+
puts flips.sample
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
option :count do
|
26
|
+
default 1
|
27
|
+
description "Specify the number of flips ( default: #{default} )"
|
28
|
+
type :stdin_integers
|
29
|
+
flag "--count"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
2
|
+
require 'command_lion'
|
3
|
+
require 'pry'
|
4
|
+
|
5
|
+
CommandLion::App.run do
|
6
|
+
name "Hello There!"
|
7
|
+
version "1.0.0"
|
8
|
+
description "A more complex 'hello' application!"
|
9
|
+
|
10
|
+
command :hello do
|
11
|
+
flag "hello"
|
12
|
+
type :strings
|
13
|
+
default "world"
|
14
|
+
description "Say hello to something! ( default: #{default} )"
|
15
|
+
|
16
|
+
action do
|
17
|
+
options[:count].argument.times do
|
18
|
+
puts "Hello #{argument}!"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
option :count do
|
23
|
+
description "Change how many times you say hello."
|
24
|
+
flag "count"
|
25
|
+
type :integer
|
26
|
+
default 1
|
27
|
+
action do
|
28
|
+
abort "Must be a positive integer greater than 1" unless argument >= 1
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
2
|
+
require 'command_lion'
|
3
|
+
require 'pry'
|
4
|
+
|
5
|
+
CommandLion::App.run do
|
6
|
+
|
7
|
+
name "Hello People!"
|
8
|
+
version "1.0.0"
|
9
|
+
description "Your typical, contrived application example."
|
10
|
+
|
11
|
+
command :hello do
|
12
|
+
description "A simple option to say hello to multiple people!"
|
13
|
+
type :strings
|
14
|
+
flag "hello"
|
15
|
+
|
16
|
+
default ["bob", "alice"]
|
17
|
+
|
18
|
+
action do
|
19
|
+
arguments.each do |argument|
|
20
|
+
next if argument == options[:ignore].argument
|
21
|
+
puts "Hello #{argument}!"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
option :ignore do
|
26
|
+
description "Optionally ignore one person."
|
27
|
+
flag "--ignore"
|
28
|
+
type :string
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
2
|
+
require 'command_lion'
|
3
|
+
require 'pry'
|
4
|
+
|
5
|
+
CommandLion::App.run do
|
6
|
+
|
7
|
+
name "Hello World"
|
8
|
+
|
9
|
+
command :hello_world do
|
10
|
+
flag "--hello-world"
|
11
|
+
action do
|
12
|
+
puts "Hello World!"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
2
|
+
require 'command_lion'
|
3
|
+
require 'pry'
|
4
|
+
|
5
|
+
class Example < CommandLion::Base
|
6
|
+
key_value :example
|
7
|
+
end
|
8
|
+
|
9
|
+
test = Example.new
|
10
|
+
|
11
|
+
test.example[:lol] = "lol"
|
12
|
+
|
13
|
+
puts test.example[:lol]
|
14
|
+
|
15
|
+
test = Example.build do
|
16
|
+
example[:lol] = "lol"
|
17
|
+
end
|
18
|
+
|
19
|
+
puts test.example[:lol]
|
data/examples/plugin.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
2
|
+
require 'command_lion'
|
3
|
+
require 'pry'
|
4
|
+
|
5
|
+
cmd = CommandLion::Command.build do
|
6
|
+
index :example
|
7
|
+
description "An example, could you guess?"
|
8
|
+
action do
|
9
|
+
puts "Works!"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
cmd2 = CommandLion::Command.build do
|
14
|
+
index :example2
|
15
|
+
description "Anouther example, could you guess?"
|
16
|
+
action do
|
17
|
+
puts "Works like a charm!"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
CommandLion::App.run do
|
22
|
+
name "Plugin Example"
|
23
|
+
description "A simple application that uses command lion's plugin command system."
|
24
|
+
plugin cmd
|
25
|
+
plugin cmd2
|
26
|
+
end
|