Sha256: 5396585064a14822229768404e92aec172247cc0b2dea737f875b80b9dcce57d

Contents?: true

Size: 900 Bytes

Versions: 7

Compression:

Stored size: 900 Bytes

Contents

#!/usr/bin/env ruby

require "como"
include Como

Spec.program( "Programmer", "2013" ) do

    command( "como_subcmd", [
       [ :subcmd,      "add",       nil,  "Add file." ],
       [ :subcmd,      "rm",        nil,  "Remove file." ],
      ], )

    subcmd( "add", [
       [ :switch,      "force",     "-fo", "Force operation." ],
       [ :opt_single,  "password",  "-p",  "User password." ],
       [ :opt_single,  "username",  "-u",  "Username." ],
       [ :single,      "file",      "-f",  "File." ],
      ] )

    check do
        one(
            '-fo',
            all( 'password', 'username' )
            )
    end

    subcmd( "rm", [
       [ :single,  "file",      "-f",  "File." ],
      ] )

end

subcmd = Opt.main.givenSubcmd

case subcmd.name
when 'add'; puts "  Adding file \"#{subcmd['file'].value}\"..."
when 'rm';  puts "  Removing file \"#{subcmd['file'].value}\"..."
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
como-0.2.4 examples/como_subcmd
como-0.2.3 examples/como_subcmd
como-0.2.2 examples/como_subcmd
como-0.2.1 examples/como_subcmd
como-0.2.0 examples/como_subcmd
como-0.1.7 examples/como_subcmd
como-0.1.6 examples/como_subcmd