parameters

Parse parameters from a string
1.0.5 Latest release released

crystal-parameters

Parse parameters from a string and output a array of strings that is usable with OptionParser#parse.

It is usefull on interactive app accepting complex commands, like text bots.

Installation

  1. Add the dependency to your shard.yml:

    dependencies:
      crystal-parameters:
        github: erdnaxeli/crystal-parameters
    
  2. Run shards install

Usage

require "option_parser"
require "parameters"


parameters = Parameters.parse("ls -lh --author --hide '* *' /tmp")
# => ["ls", "-lh", "--author", "--hide", "* *", "/tmp"]

if parameters
  OptionParser.parse(parameters) do |parser|
    parser.on("ls", "list files") { }
  end
end

Development

Make sure to run make test and make lint :)

Contributing

  1. Fork it (https://github.com/erdnaxeli/crystal-parameters/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

parameters:
  github: erdnaxeli/crystal-parameters
  version: ~> 1.0.5
License MIT
Crystal >=0.35.1, <2

Authors

  • Alexandre Morignot <erdnaxeli@cervoi.se

Dependencies 0

Development Dependencies 1

  • ameba ~>0.13.2
    {'github' => 'crystal-ameba/ameba', 'version' => '~>0.13.2'}

Dependents 0

Last synced .
search fire star recently