Sha256: 1ba1f4501dbe1be42a6cd8ab763c86fe59e97eeade470f906950df5f530a9c77

Contents?: true

Size: 902 Bytes

Versions: 3

Compression:

Stored size: 902 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.master.givenSubcmd

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
como-0.1.5 examples/como_subcmd
como-0.1.4 examples/como_subcmd
como-0.1.3 examples/como_subcmd