github.com/erdnaxeli/crystal-parameters

Parse parameters from a string

0 stars
1 dependent
License: MIT

Nothing has been indexed for 1.0.0 yet. The tag is recorded, its shard.yml has not been read, so the manifest and dependency list below are empty because they are unknown rather than because they are absent.

Installation

# Add this to your shard.yml
dependencies:
  parameters:
    github: erdnaxeli/crystal-parameters
    version: ~> 1.0.0

Then run:

shards install

shard.yml

No shard.yml has been indexed for 1.0.0. You can read it on the repository.

Dependencies

Unknown: the shard.yml for this version has not been read yet.

README

This README is the one indexed from the repository at its latest ref, not from the tag for this version.

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