Happy !

philippeback / GetOpt

Project infos

License MIT
Tags
Creation date 2014-12-02
Website

Monticello registration

About GetOpt

Port of Ian Piumarta's GetOpt to Pharo 3.0

| files searchPath outputPath verbose args  getopt |
files := OrderedCollection new.
searchPath := OrderedCollection new.
outputPath := nil.
verbose := false.

args := CommandLineArguments default.
args initializeWithArguments: #('-l' 'libs' '-o' 'output' '-v').

getopt := GetOpt new.
getopt
    at: $l put: [ :opt :arg | searchPath add: arg ];
    at: $o put: [ :opt :arg | outputPath := arg ];
    at: $v put: [ :opt | verbose := true ];
    at: $? put: [ :opt | self error: 'illegal option: -' , opt asString ];
    default: [ :arg | files add: arg ].
getopt parse: args arguments.

self assert: verbose = true.
self assert: outputPath = 'output'.
self assert: searchPath size = 1