diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..6eec910 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,24 @@ +name: Test +on: + push: + schedule: + - cron: '0 0 1 * *' # monthly +jobs: + linux: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + compiler: [gcc, clang] + cpp11: [0, 1] + steps: + - uses: actions/checkout@v3 + - run: make test WARN=1 + env: + CC: ${{ matrix.compiler }} + CPP11: ${{ matrix.cpp11 }} + macos: + runs-on: macos-latest + steps: + - uses: actions/checkout@v3 + - run: make test WARN=1 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 4c0b01f..0000000 --- a/.travis.yml +++ /dev/null @@ -1,12 +0,0 @@ ---- -language: cpp -os: - - linux - - osx -compiler: - - clang - - gcc -env: - - CPP11=0 - - CPP11=1 -script: make test WARN=1 diff --git a/OptionParser.cpp b/OptionParser.cpp index d850052..65d2726 100644 --- a/OptionParser.cpp +++ b/OptionParser.cpp @@ -216,7 +216,7 @@ void OptionParser::handle_short_opt(const string& opt, const string& arg) { value = arg.substr(2); if (value == "") { if (_remaining.empty()) - error("-" + opt + " " + _("option requires an argument")); + error("-" + opt + " " + _("option requires 1 argument")); value = _remaining.front(); _remaining.pop_front(); } @@ -269,7 +269,7 @@ void OptionParser::handle_long_opt(const string& optstr) { } if (option._nargs == 1 and value == "") - error("--" + opt + " " + _("option requires an argument")); + error("--" + opt + " " + _("option requires 1 argument")); process_opt(option, string("--") + opt, value); } diff --git a/t/testprog b/t/testprog index aeae0de..acf20bd 100755 --- a/t/testprog +++ b/t/testprog @@ -1,23 +1,22 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- mode: python; coding: utf-8; indent-tabs-mode: nil -*- # vim: set filetype=python fileencoding=utf-8 expandtab sw=4 sts=4: -import sys import os from optparse import OptionParser, OptionGroup, SUPPRESS_HELP, SUPPRESS_USAGE -class MyCallback(object): +class MyCallback: def __init__(self): self.counter = 0 def __call__(self, option, opt, val, parser): self.counter += 1 - print "--- MyCallback --- " + str(self.counter) + ". time called" - print "--- MyCallback --- option.action(): " + option.action - print "--- MyCallback --- option.type(): " + (option.type if option.type else "") - print "--- MyCallback --- opt: " + opt - print "--- MyCallback --- val: " + (val if val else "") - print "--- MyCallback --- parser.usage(): " + parser.usage - print + print("--- MyCallback --- " + str(self.counter) + ". time called") + print("--- MyCallback --- option.action(): " + option.action) + print("--- MyCallback --- option.type(): " + (option.type if option.type else "")) + print("--- MyCallback --- opt: " + opt) + print("--- MyCallback --- val: " + (val if val else "")) + print("--- MyCallback --- parser.usage(): " + parser.usage) + print() def main(): usage = \ @@ -112,40 +111,40 @@ def main(): options, args = parser.parse_args() - print "clear:", ("false" if options.no_clear else "true") - print "string:", options.string if options.string else "" - print "clause:", options.clause - print "k:", options.k if options.k else "" - print "verbosity:", options.verbosity - print "number:", options.number - print "int:", options.int - print "float: %g" % (options.float,) + print("clear:", ("false" if options.no_clear else "true")) + print("string:", options.string if options.string else "") + print("clause:", options.clause) + print("k:", options.k if options.k else "") + print("verbosity:", options.verbosity) + print("number:", options.number) + print("int:", options.int) + print("float: %g" % (options.float,)) c = complex(0) if options.complex is not None: c = options.complex - print "complex: (%g,%g)" % (c.real, c.imag) - print "choices:", options.choices if options.choices else "" - print "choices-list:", options.choices_list if options.choices_list else "" - print "more:", - print ", ".join(options.more if options.more else []) + print("complex: (%g,%g)" % (c.real, c.imag)) + print("choices:", options.choices if options.choices else "") + print("choices-list:", options.choices_list if options.choices_list else "") + print("more: ", end="") + print(", ".join(options.more if options.more else [])) - print "more_milk:" + print("more_milk:") for opt in (options.more_milk if options.more_milk else []): - print "-", opt + print("-", opt) - print "hidden:", options.hidden if options.hidden else "" - print "group:", ("true" if options.g else "false") + print("hidden:", options.hidden if options.hidden else "") + print("group:", ("true" if options.g else "false")) - print "option1:", options.option1 - print "option2:", options.option2 + print("option1:", options.option1) + print("option2:", options.option2) - print "width:", options.width - print "height:", options.height + print("width:", options.width) + print("height:", options.height) - print - print "leftover arguments: " + print() + print("leftover arguments: ") for arg in args: - print "arg: " + arg + print("arg: " + arg) return 0 diff --git a/test.sh b/test.sh index a0de60c..72b9656 100755 --- a/test.sh +++ b/test.sh @@ -43,6 +43,7 @@ c --no-clear c --clear --no-clear c --clear --no-clear --clear c --string "foo bar" +c -n # requires argument c --string # requires argument c -x foo c --clause foo