Sha256: 09fffb555fa3ec882a3bb85f07fb651fe960237d8d643213a879eebd60c378f3

Contents?: true

Size: 871 Bytes

Versions: 1

Compression:

Stored size: 871 Bytes

Contents

= Usage Parsing

Require usage library.

  require 'clio/usage'

A single toplevel option.

  usage = Clio::Usage.new
  usage.option('force')
  cli = usage.parse('--force')

  cli.options.assert == {:force=>true}

A single toplevel option with an alias.

  usage = Clio::Usage.new
  usage.option('force', 'f')
  cli = usage.parse('-f')

  cli.options.assert == {:force=>true}

A subcommand.

  usage = Clio::Usage.new
  usage.command('foo')
  cli = usage.parse('foo')

  cli.command.assert == 'foo'
  cli.commands.assert == ['foo']

A subcommand with an option.

  usage = Clio::Usage.new
  usage.command('foo')
  usage.command('foo').option('verbose')
  cli = usage.parse('foo --verbose')

  cli.command.assert == 'foo'
  cli.commands.assert == ['foo']
  cli.options.assert == {:verbose=>true}

  cli[0].options.assert == {}
  cli[1].options.assert == {:verbose=>true}

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
clio-0.3.0 spec/usage/parse.rd