--
--	getoptlong.occ - test command-line option parsing
--	Copyright (C) 2008 University of Kent
--
--	This program is free software; you can redistribute it and/or modify
--	it under the terms of the GNU General Public License as published by
--	the Free Software Foundation; either version 2 of the License, or
--	(at your option) any later version.
--
--	This program is distributed in the hope that it will be useful,
--	but WITHOUT ANY WARRANTY; without even the implied warranty of
--	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
--	GNU General Public License for more details.
--
--	You should have received a copy of the GNU General Public License
--	along with this program; if not, write to the Free Software
--	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
--

#INCLUDE "file.module"
#INCLUDE "course.module"

PROC main (CHAN BYTE out!)
  INITIAL MOBILE []MOBILE []BYTE options IS MOBILE [8]MOBILE []BYTE:
  SEQ
    options[0] := "x"
    options[1] := "y"
    options[2] := "a="
    options[3] := "b="
    options[4] := "foo"
    options[5] := "bar"
    options[6] := "baz="
    options[7] := "quux="
    CHAN GETOPT.LONG opts:
    PAR
      file.get.long.options (options, opts!)
      INITIAL BOOL running IS TRUE:
      WHILE running
        MOBILE []BYTE o, a:
        opts ? CASE
          opt; o
            SEQ
              out.string ("opt *'", 0, out!)
              out.string (o, 0, out!)
              out.string ("*'; ", 0, out!)
          opt.arg; o; a
            SEQ
              out.string ("opt.arg *'", 0, out!)
              out.string (o, 0, out!)
              out.string ("*' *'", 0, out!)
              out.string (a, 0, out!)
              out.string ("*'; ", 0, out!)
          arg; a
            SEQ
              out.string ("arg *'", 0, out!)
              out.string (a, 0, out!)
              out.string ("*'; ", 0, out!)
          bad; o
            SEQ
              out.string ("bad *'", 0, out!)
              out.string (o, 0, out!)
              out.string ("*'; ", 0, out!)
          done
            SEQ
              out.string ("done*n", 0, out!)
              running := FALSE
:
