Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
38 changed files
with
1,254 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/usr/bin/env ruby | ||
$: << File.expand_path('../../lib', __FILE__) | ||
|
||
require 'erb' | ||
|
||
def example(path) | ||
str = File.read("examples/#{path}") | ||
str.lines[5..-1].join | ||
end | ||
|
||
erb = ERB.new(File.read('var/README.erb.md'), nil, '-') | ||
puts erb.result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/usr/bin/env ruby | ||
$: << File.expand_path('lib') | ||
|
||
require 'cl' | ||
|
||
class Add < Cl::Cmd | ||
opt '--to GROUP', alias: :group | ||
|
||
def run | ||
p opts, to, to?, group, group? | ||
end | ||
end | ||
|
||
Cl.new('owners').run(%w(add --to one)) | ||
|
||
# Output: | ||
# | ||
# {"to" => "one"} | ||
# "one" | ||
# true | ||
# "one" | ||
# true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/usr/bin/env ruby | ||
$: << File.expand_path('lib') | ||
|
||
require 'cl' | ||
|
||
class Add < Cl::Cmd | ||
args :owners | ||
|
||
def run | ||
p owners | ||
end | ||
end | ||
|
||
Cl.new('owners').run(%w(add one,two)) | ||
|
||
# => ["one,two"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/env ruby | ||
$: << File.expand_path('lib') | ||
|
||
require 'cl' | ||
|
||
class Add < Cl::Cmd | ||
opt '--to GROUP', type: :array | ||
|
||
def run | ||
p to | ||
end | ||
end | ||
|
||
Cl.new('owners').run(%w(add --to one --to two)) | ||
|
||
# Output: | ||
# | ||
# ["one", "two"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/env ruby | ||
$: << File.expand_path('lib') | ||
|
||
require 'cl' | ||
|
||
class Add < Cl::Cmd | ||
opt '--to GROUP', default: 'default' | ||
|
||
def run | ||
p to | ||
end | ||
end | ||
|
||
Cl.new('owners').run(%w(add)) | ||
|
||
# Output: | ||
# | ||
# "default" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/usr/bin/env ruby | ||
$: << File.expand_path('lib') | ||
|
||
require 'cl' | ||
|
||
class Add < Cl::Cmd | ||
opt '--to GROUP' | ||
opt '--target GROUP', deprecated: 'Deprecated: --target' | ||
|
||
def run | ||
p to, deprecated_opts | ||
end | ||
end | ||
|
||
Cl.new('owners').run(%w(add --target one)) | ||
|
||
# Output: | ||
# | ||
# "one" | ||
# {:target=>'Deprecated: --target'} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/usr/bin/env ruby | ||
$: << File.expand_path('lib') | ||
|
||
require 'cl' | ||
|
||
class Add < Cl::Cmd | ||
opt '--to GROUP', alias: :target, deprecated: :target | ||
|
||
def run | ||
p to, deprecated_opts | ||
end | ||
end | ||
|
||
Cl.new('owners').run(%w(add --target one)) | ||
|
||
# Output: | ||
# | ||
# "one" | ||
# {:target=>:to} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/env ruby | ||
$: << File.expand_path('lib') | ||
|
||
require 'cl' | ||
|
||
class Add < Cl::Cmd | ||
opt '--to GROUP', downcase: true | ||
|
||
def run | ||
p to | ||
end | ||
end | ||
|
||
Cl.new('owners').run(%w(add --to ONE)) | ||
|
||
# Output: | ||
# | ||
# "one" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/usr/bin/env ruby | ||
$: << File.expand_path('lib') | ||
|
||
require 'cl' | ||
|
||
class Add < Cl::Cmd | ||
opt '--to GROUP', enum: %w(one two) | ||
|
||
def run | ||
p to | ||
end | ||
end | ||
|
||
Cl.new('owners').run(%w(add --to one)) | ||
|
||
# Output: | ||
# | ||
# "one" | ||
|
||
Cl.new('owners').run(%w(add --to unknown)) | ||
|
||
# Unknown value: to=unknown (known values: one, two) | ||
# | ||
# Usage: enum add [options] | ||
# | ||
# Options: ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/usr/bin/env ruby | ||
$: << File.expand_path('lib') | ||
|
||
require 'cl' | ||
|
||
class Add < Cl::Cmd | ||
opt '--to GROUP', example: 'group-one' | ||
end | ||
|
||
Cl.new('owners').run(%w(add --help)) | ||
|
||
# Usage: example add [options] | ||
# | ||
# Options: | ||
# | ||
# --to GROUP type: string, e.g.: group-one | ||
# --help Get help on this command |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env ruby | ||
$: << File.expand_path('lib') | ||
|
||
require 'cl' | ||
|
||
class Add < Cl::Cmd | ||
opt '--to GROUP', format: /^\w+$/ | ||
|
||
def run | ||
p to | ||
end | ||
end | ||
|
||
Cl.new('owners').run(%w(add --to one)) | ||
|
||
# Output: | ||
# | ||
# "one" | ||
|
||
Cl.new('owners').run(['add', '--to', 'does not match!']) | ||
|
||
Invalid format: to (format: /^\w+$/) | ||
|
||
Usage: format add [options] | ||
|
||
Options: | ||
|
||
--to GROUP type: string, format: /^\w+$/ | ||
--help Get help on this command |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/env ruby | ||
$: << File.expand_path('lib') | ||
|
||
require 'cl' | ||
|
||
class Add < Cl::Cmd | ||
opt '--to GROUP' | ||
opt '--hidden', internal: true | ||
end | ||
|
||
Cl.new('owners').run(%w(add --help)) | ||
|
||
# Usage: example add [options] | ||
# | ||
# Options: | ||
# | ||
# --to GROUP type: string, e.g.: group-one | ||
# --help Get help on this command |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env ruby | ||
$: << File.expand_path('lib') | ||
|
||
require 'cl' | ||
|
||
class Add < Cl::Cmd | ||
opt '--retries COUNT', max: 5, type: :integer | ||
|
||
def run | ||
p retries | ||
end | ||
end | ||
|
||
Cl.new('owners').run(%w(add --retries 1)) | ||
|
||
# Output: | ||
# | ||
# 1 | ||
|
||
Cl.new('owners').run(%w(add --retries 10)) | ||
|
||
# Exceeds max value: retries (max: 5) | ||
# | ||
# Usage: max add [options] | ||
# | ||
# Options: | ||
# | ||
# --retries COUNT type: integer, max: 5 | ||
# --help Get help on this command |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/usr/bin/env ruby | ||
$: << File.expand_path('lib') | ||
|
||
require 'cl' | ||
|
||
class Add < Cl::Cmd | ||
opt '--to GROUP' | ||
|
||
def run | ||
p opts, to, to? | ||
end | ||
end | ||
|
||
Cl.new('owners').run(%w(add --to one)) | ||
|
||
# Output: | ||
# | ||
# {"to" => "one"} | ||
# "one" | ||
# true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env ruby | ||
$: << File.expand_path('lib') | ||
|
||
require 'cl' | ||
|
||
class Add < Cl::Cmd | ||
opt '--to GROUP', required: true | ||
|
||
def run | ||
p to | ||
end | ||
end | ||
|
||
Cl.new('owners').run(%w(add --to one)) | ||
|
||
# Output: | ||
# | ||
# "one" | ||
|
||
Cl.new('owners').run(%w(add)) | ||
|
||
# Missing required option: to | ||
# | ||
# Usage: required add [options] | ||
# | ||
# Options: | ||
# | ||
# --to GROUP type: string, required: true | ||
# --help Get help on this command |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/usr/bin/env ruby | ||
$: << File.expand_path('lib') | ||
|
||
require 'cl' | ||
|
||
class Add < Cl::Cmd | ||
# read DNF, i.e. "apikey OR username AND password | ||
required :api_key, [:username, :password] | ||
|
||
opt '--api_key KEY' | ||
opt '--username NAME' | ||
opt '--password PASS' | ||
|
||
def run | ||
p to, retries | ||
end | ||
end | ||
|
||
Cl.new('owners').run(%w(add --to one --retries 1)) | ||
|
||
# Output: | ||
# | ||
# "one" | ||
# 1 | ||
|
||
Cl.new('owners').run(%w(add --retries 1)) | ||
|
||
# Missing option: to (required by retries) | ||
# | ||
# Usage: requires add [options] | ||
# | ||
# Options: | ||
# | ||
# --to GROUP type: string | ||
# --retries INT type: string, requires: to | ||
# --help Get help on this command |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/usr/bin/env ruby | ||
$: << File.expand_path('lib') | ||
|
||
require 'cl' | ||
|
||
class Add < Cl::Cmd | ||
opt '--to GROUP' | ||
opt '--retries INT', requires: :to | ||
|
||
def run | ||
p to, retries | ||
end | ||
end | ||
|
||
Cl.new('owners').run(%w(add --to one --retries 1)) | ||
|
||
# Output: | ||
# | ||
# "one" | ||
# 1 | ||
|
||
Cl.new('owners').run(%w(add --retries 1)) | ||
|
||
# Missing option: to (required by retries) | ||
# | ||
# Usage: requires add [options] | ||
# | ||
# Options: | ||
# | ||
# --to GROUP type: string | ||
# --retries INT type: string, requires: to | ||
# --help Get help on this command |
Oops, something went wrong.