LIDIA

DESCRIPTION:

Lidia is a yml based command contructor class. Aims to be easy to use and to provide an easy way to remember tons of commands

SYNOPSIS:

Lidia’s is written to provide an easy way to manage commands calls. Commands structure can be defined in an easy yaml file.

# $your editor ls.lidia.yml
: ==parameters:
  :columns:
    :option: -l
    :description:  listing format@

By default, lidia loads definition files from gem installation folder ../source, or you can pass with :definition_file the location

>> Lidia::Command.new('ls', {}, :definition_file => 'ls.lidia.yml')
=> Lidia::Command 
      + name: ls,
      + definition file at:/var/www/lidia/sources/ls.lidia.yml
      + parameters:
        * name: columns               group: option    , value: nil

Values can be passed as argument on new, or creating by block

>> Lidia::Command.new('ls', {:columns => true })
?> Lidia::Command.new('ls') do |l|
?>   l.columns = true
>> end
=> Lidia::Command 
      + name: ls,
      + definition file at:/var/www/lidia/sources/ls.lidia.yml
      + parameters:
        * name: columns               group: option    , value: true

Once u have defined all the parameters that your command will use, define which actions can be done, por example, list_by_columns

# your editor ls.lidia.yml
# :actions:
#   :list_by_columns:
#     :parameters:
#       :required: [ :columns ]

Now ask for command_for lidia list_by_columns

>> l = Lidia::Command.new('ls', {:columns => nil })
=> Lidia::Command 
      + name: ls,
      + definition file at:/var/www/lidia/sources/ls.lidia.yml
      + parameters:
        * name: columns               group: option    , value: nil 

>> l.command_for(:list_by_columns)
ArgumentError: Parameter columns required but not valid

Ooops, parameter -l is required, to list_by_columns action, so set it to true

>> l.columns = true
=> true
>> l.command_for(:list_by_columns)
=> "/bin/ls -l"

We want sometimes, list other directory. so prepare defintion file to get an argument

# $your editor ls.lidia.yml
# :parameters:
#   :list_what:
#     :description:  what do u want to list?

this option can be used for listing_by_columns to, but it is not mandatary

# $your editor ls.lidia.yml
# :actions:
#   :list_by_columns:
#     :parameters:
#       :required: [ :columns ]
#       :optional: [ :list_what ]

Now, no exceptions is raised, but argument can be used

>> l = Lidia::Command.new('ls', {:columns => true })
=> Lidia::Command 
      + name: ls,
      + definition file at:/var/www/lidia/sources/ls.lidia.yml
      + parameters:
        * name: columns               group: option    , value: true 
        * name: list_what             group: argument  , value: nil 

>> l.command_for(:list_by_columns)
=> "/bin/ls -l "
>> l.list_what = '/tmp'
=> "/tmp"
>> l.command_for(:list_by_columns)
=> "/bin/ls -l   \"/tmp\" "

REQUIREMENTS:

  • FIX (list of requirements)

INSTALL:

  • FIX (sudo gem install, anything else)

LICENSE:

(The MIT License)

Copyright © 2010 FIXME full name

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘Software’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.