#!/usr/bin/env ruby require "como" include Como Spec.program( "Como Tester", "2013", { :header => "Addition heading info.", :footer => "Addition footer info.", :subcheck => false, :check_missing => false, :tab => 10, :help_exit => false, :error_exit => false, } ) do subcmd( "como_subcmd_config", [ [ :opt_single, "password", "-p", "User password." ], [ :opt_multi, "username", "-u", "Username(s)." ], [ :silent, "terminator","-", "Terminator." ], [ :subcmd, "add", nil, "Add file to repo." ], [ :subcmd, "rm", nil, "Remove file from repo." ], [ :subcmd, "commit", nil, "Commit (pending) changes to repo." ], ], ) checkRule do any( 'password', 'username' ) end subcmd( "add", [ [ :switch, "force", "-fo", "Force operation." ], [ :opt_single, "username", "-u", "Username." ], [ :single, "file", "-f", "File." ], ], { :rulehelp => true, :help_exit => true } ) checkRule do one( 'file', 'username', inv( '-fo' ) ) end subcmd( "rm", [ [ :exclusive, "help", "-hm", "Help for me." ], [ :switch, "force", "-fo", "Force operation." ], [ :opt_single, "file", "-f", "File." ], ], { :autohelp => false, :header => nil, :footer => nil, } ) subcmd( "commit", [ [ :switch, "quiet", "-q", "Quiet operation." ], [ :opt_single, "username", "-u", "Username." ], [ :default, "File(s) to commit." ], ], { :tab => 14, :help_exit => true, :error_exit => false, } ) end def displayOptions( opt ) puts "Options for: #{opt.name}" opt.each do |o| puts " Given \"#{o.name}\": #{o.given}" end opt.each_given do |o| puts " Value \"#{o.name}\": #{o.value}" end sub = opt.givenSubcmd displayOptions( sub ) if sub end displayOptions( Opt.main ) if Opt.external puts "External: #{Opt.external}" end