Skip to content

Commit 2265d64

Browse files
authored
Merge pull request #7 from weisslj/github-actions
Switch from Travis CI to GitHub Actions
2 parents 2ec0b7a + 4679b0b commit 2265d64

File tree

5 files changed

+60
-48
lines changed

5 files changed

+60
-48
lines changed

.github/workflows/test.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Test
2+
on:
3+
push:
4+
schedule:
5+
- cron: '0 0 1 * *' # monthly
6+
jobs:
7+
linux:
8+
runs-on: ubuntu-latest
9+
strategy:
10+
fail-fast: false
11+
matrix:
12+
compiler: [gcc, clang]
13+
cpp11: [0, 1]
14+
steps:
15+
- uses: actions/checkout@v3
16+
- run: make test WARN=1
17+
env:
18+
CC: ${{ matrix.compiler }}
19+
CPP11: ${{ matrix.cpp11 }}
20+
macos:
21+
runs-on: macos-latest
22+
steps:
23+
- uses: actions/checkout@v3
24+
- run: make test WARN=1

.travis.yml

Lines changed: 0 additions & 12 deletions
This file was deleted.

OptionParser.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ void OptionParser::handle_short_opt(const string& opt, const string& arg) {
216216
value = arg.substr(2);
217217
if (value == "") {
218218
if (_remaining.empty())
219-
error("-" + opt + " " + _("option requires an argument"));
219+
error("-" + opt + " " + _("option requires 1 argument"));
220220
value = _remaining.front();
221221
_remaining.pop_front();
222222
}
@@ -269,7 +269,7 @@ void OptionParser::handle_long_opt(const string& optstr) {
269269
}
270270

271271
if (option._nargs == 1 and value == "")
272-
error("--" + opt + " " + _("option requires an argument"));
272+
error("--" + opt + " " + _("option requires 1 argument"));
273273

274274
process_opt(option, string("--") + opt, value);
275275
}

t/testprog

Lines changed: 33 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22
# -*- mode: python; coding: utf-8; indent-tabs-mode: nil -*-
33
# vim: set filetype=python fileencoding=utf-8 expandtab sw=4 sts=4:
44

5-
import sys
65
import os
76
from optparse import OptionParser, OptionGroup, SUPPRESS_HELP, SUPPRESS_USAGE
87

9-
class MyCallback(object):
8+
class MyCallback:
109
def __init__(self):
1110
self.counter = 0
1211
def __call__(self, option, opt, val, parser):
1312
self.counter += 1
14-
print "--- MyCallback --- " + str(self.counter) + ". time called"
15-
print "--- MyCallback --- option.action(): " + option.action
16-
print "--- MyCallback --- option.type(): " + (option.type if option.type else "")
17-
print "--- MyCallback --- opt: " + opt
18-
print "--- MyCallback --- val: " + (val if val else "")
19-
print "--- MyCallback --- parser.usage(): " + parser.usage
20-
print
13+
print("--- MyCallback --- " + str(self.counter) + ". time called")
14+
print("--- MyCallback --- option.action(): " + option.action)
15+
print("--- MyCallback --- option.type(): " + (option.type if option.type else ""))
16+
print("--- MyCallback --- opt: " + opt)
17+
print("--- MyCallback --- val: " + (val if val else ""))
18+
print("--- MyCallback --- parser.usage(): " + parser.usage)
19+
print()
2120

2221
def main():
2322
usage = \
@@ -112,40 +111,40 @@ def main():
112111

113112
options, args = parser.parse_args()
114113

115-
print "clear:", ("false" if options.no_clear else "true")
116-
print "string:", options.string if options.string else ""
117-
print "clause:", options.clause
118-
print "k:", options.k if options.k else ""
119-
print "verbosity:", options.verbosity
120-
print "number:", options.number
121-
print "int:", options.int
122-
print "float: %g" % (options.float,)
114+
print("clear:", ("false" if options.no_clear else "true"))
115+
print("string:", options.string if options.string else "")
116+
print("clause:", options.clause)
117+
print("k:", options.k if options.k else "")
118+
print("verbosity:", options.verbosity)
119+
print("number:", options.number)
120+
print("int:", options.int)
121+
print("float: %g" % (options.float,))
123122
c = complex(0)
124123
if options.complex is not None:
125124
c = options.complex
126-
print "complex: (%g,%g)" % (c.real, c.imag)
127-
print "choices:", options.choices if options.choices else ""
128-
print "choices-list:", options.choices_list if options.choices_list else ""
129-
print "more:",
130-
print ", ".join(options.more if options.more else [])
125+
print("complex: (%g,%g)" % (c.real, c.imag))
126+
print("choices:", options.choices if options.choices else "")
127+
print("choices-list:", options.choices_list if options.choices_list else "")
128+
print("more: ", end="")
129+
print(", ".join(options.more if options.more else []))
131130

132-
print "more_milk:"
131+
print("more_milk:")
133132
for opt in (options.more_milk if options.more_milk else []):
134-
print "-", opt
133+
print("-", opt)
135134

136-
print "hidden:", options.hidden if options.hidden else ""
137-
print "group:", ("true" if options.g else "false")
135+
print("hidden:", options.hidden if options.hidden else "")
136+
print("group:", ("true" if options.g else "false"))
138137

139-
print "option1:", options.option1
140-
print "option2:", options.option2
138+
print("option1:", options.option1)
139+
print("option2:", options.option2)
141140

142-
print "width:", options.width
143-
print "height:", options.height
141+
print("width:", options.width)
142+
print("height:", options.height)
144143

145-
print
146-
print "leftover arguments: "
144+
print()
145+
print("leftover arguments: ")
147146
for arg in args:
148-
print "arg: " + arg
147+
print("arg: " + arg)
149148

150149
return 0
151150

test.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ c --no-clear
4343
c --clear --no-clear
4444
c --clear --no-clear --clear
4545
c --string "foo bar"
46+
c -n # requires argument
4647
c --string # requires argument
4748
c -x foo
4849
c --clause foo

0 commit comments

Comments
 (0)