Ruby Command-Line-Interface API. Inspired by iproute2
Go to file
Denis Knauf d3930c00bc opts-mething redesign. completion improved. example: args-command for demonstrate arguments and options. 2021-11-30 15:23:05 +01:00
bin opts-mething redesign. completion improved. example: args-command for demonstrate arguments and options. 2021-11-30 15:23:05 +01:00
lib opts-mething redesign. completion improved. example: args-command for demonstrate arguments and options. 2021-11-30 15:23:05 +01:00
.gitignore file-seperated classes. interactive CLI. 2020-12-27 23:00:53 +01:00
Gemfile init 2020-12-13 15:54:09 +01:00
Gemfile.lock init 2020-12-13 15:54:09 +01:00
LICENSE.txt init 2020-12-13 15:54:09 +01:00
README.adoc init 2020-12-13 15:54:09 +01:00
Rakefile init 2020-12-13 15:54:09 +01:00
dencli.gemspec init 2020-12-13 15:54:09 +01:00

README.adoc

# DenCli

Provides a Command-Line-Interface-API for providing commands.

## Installation

Add this line to your application's Gemfile:

[source,ruby]
----
gem 'dencli'
----

And then execute:

[source,sh]
----
$ bundle install
----

Or install it yourself as:

[source,sh]
----
$ gem install dencli
----

## Usage

[source,ruby]
----
#!/usr/bin/env ruby

require 'dencli'

cli = CLI.new "This is an example for generate a CLI-API"
cli.cmd( :example, "I have an example command") { STDERR.puts "This is an example" }
cli.cmd( :help) {|*args| STDERR.puts cli.help(*args) }

cli.sub( :more, "Sub-Commands are also possible with a new cli") do |sub|
	sub.cmd( :help) {|*args| STDERR.puts cli.help( 'more', *args) }
	sub.cmd( :example, "Here is an example, too") { STDERR.puts "This is an other example" }
	sub.cmd( :foo, "BAR") { STDERR.puts "FOO bar"}
	
	sub.sub( :deeper, "You want to have Sub-Sub-Commands?") do |sub2|
		sub2.cmd( :help) {|*args| STDERR.puts cli.help( 'more', 'deeper', *args) }
		sub2.cmd( :last, "The last example") { STDERR.puts "The last example" }
		
		sub2.sub( :'sub-commands', "Endless Sub-Sub- ...") do |sub3|
			sub2.cmd( :help) {|*args| STDERR.puts cli.help( 'more', 'deeper', 'sub-commands', *args) }
			sub3.cmd( :hehe, "The real last example", min: 2) { STDERR.puts "Trust me!" }
		end
	end
end
 
cli.call *ARGV
----

## Development

## Contributing

Bug reports and pull requests are welcome on git at https://git.denkn.at/deac/dencli.