项目作者: bew

项目描述 :
CLI flags parser
高级语言: Crystal
项目地址: git://github.com/bew/flag_parser.cr.git
创建时间: 2016-10-08T21:10:55Z
项目社区:https://github.com/bew/flag_parser.cr

开源协议:MIT License

下载


flag_parser

Yet another command line flag parser library :)

Installation

Add this to your application’s shard.yml:

  1. dependencies:
  2. flag_parser:
  3. github: bew/flag_parser.cr

Usage

  1. require "flag_parser"
  2. value = 0
  3. args = %w(--option 42)
  4. FlagParser.parse args do |parser|
  5. parser.add_rule "VALUE", FlagParser::Rule::NUM
  6. parser.on "-o VALUE", "--option VALUE", doc: "Set option value" do |(a_value)|
  7. value = a_value.to_i
  8. end
  9. end
  10. puts value # => 42

TODO: Write more usage instructions here

TODO

[ ] execution policy (1. parse all THEN exec handler, 2. or parse AND exec when possible)

  1. 1. will be hard (impossible ?) when a callback comsume arguments based on runtime state.. ?

[ ] recursive options : options that are applied on subparsers
[ ] Exceptions on missing or no match

Contributing

  1. Fork it ( https://github.com/bew/flag_parser.cr/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

  • bew Benoit de Chezelles - creator, maintainer