Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -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
12 changes: 0 additions & 12 deletions .travis.yml

This file was deleted.

4 changes: 2 additions & 2 deletions OptionParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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);
}
Expand Down
67 changes: 33 additions & 34 deletions t/testprog
Original file line number Diff line number Diff line change
@@ -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 = \
Expand Down Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down