Sha256: 02867b08f625bcb988156cb49decf9f5eb8e56d065149f8dd7c4b28dfba7e661
Contents?: true
Size: 1005 Bytes
Versions: 1
Compression:
Stored size: 1005 Bytes
Contents
= Commandline Definition using Core Notation Require commandline library. require 'clio/commandline' Fake that we running an executable called 'test'. $0 = 'test' Create a new commandline object. @cmd = Clio::Commandline.new We can define a subcommand using #command on #usage. @cmd.usage.command('foo') @cmd.to_s.assert == 'test foo' We can define a toplevel switch using #switch. @cmd.usage.switch('verbose') @cmd.to_s.assert == 'test [--verbose] foo' Switches can have aliases. @cmd.usage.switch(:verbose, :v) @cmd.to_s.assert == 'test [-v --verbose] foo' There can be mulitple subcommands. @cmd.usage.command('foo bar') @cmd.to_s.assert == 'test [-v --verbose] foo bar' Let's bring it all together in one example. cmd = Clio::Commandline.new cmd.usage.switch(:verbose, :v) cmd.usage.switch(:force, :f) cmd.usage.command('foo') cmd.usage.command('bar') cmd.to_s.assert == 'test [-v --verbose] [-f --force] [foo | bar]'
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
clio-0.3.0 | spec/commandline/define.rd |