Skip to content

Commit b36fda8

Browse files
committed
Add -P pragma=value command line option to roundup-admin.
To set pragmas when using non-interactive mode, or set on command line when going into interactive mode. Also changed specification test to use command line pragma setting rather than interactive. This tests the -P option without having to run an extra test. Docs updated as well.
1 parent 6777f52 commit b36fda8

File tree

5 files changed

+16
-7
lines changed

5 files changed

+16
-7
lines changed

CHANGES.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ Features:
2121
- issue2551103 - add pragma 'display_protected' to roundup-admin. If
2222
true, print protected attributes like id, activity, actor...
2323
when using display or specification subcommands. (John Rouillard)
24+
- add -P pragma=value command line option to roundup-admin. Allows
25+
setting pragmas when using non-interactive mode. (John Rouillard)
2426

2527
2023-07-13 2.3.0
2628

doc/admin_guide.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,6 +1248,8 @@ The basic usage is::
12481248
-S <string> -- when outputting lists of data, string-separate them
12491249
-s -- when outputting lists of data, space-separate them.
12501250
Same as '-S " "'.
1251+
-P pragma=value -- Set a pragma on command line rather than interactively.
1252+
Can be used multiple times.
12511253
-V -- be verbose when importing
12521254
-v -- report Roundup and Python versions (and quit)
12531255

roundup/admin.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,8 @@ def usage(self, message=''):
173173
-S <string> -- when outputting lists of data, string-separate them
174174
-s -- when outputting lists of data, space-separate them.
175175
Same as '-S " "'.
176+
-P pragma=value -- Set a pragma on command line rather than interactively.
177+
Can be used multiple times.
176178
-V -- be verbose when importing
177179
-v -- report Roundup and Python versions (and quit)
178180
@@ -2114,7 +2116,7 @@ def interactive(self):
21142116

21152117
def main(self):
21162118
try:
2117-
opts, args = getopt.getopt(sys.argv[1:], 'i:u:hcdsS:vV')
2119+
opts, args = getopt.getopt(sys.argv[1:], 'i:u:hcdP:sS:vV')
21182120
except getopt.GetoptError as e:
21192121
self.usage(str(e))
21202122
return 1
@@ -2160,6 +2162,8 @@ def main(self):
21602162
self.separator = ' '
21612163
elif opt == '-d':
21622164
self.print_designator = 1
2165+
elif opt == '-P':
2166+
self.do_pragma([arg])
21632167
elif opt == '-u':
21642168
login_opt = arg.split(':')
21652169
self.name = login_opt[0]

share/man/man1/roundup-admin.1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ When outputting lists of data, separate items with given string.
2929
When outputting lists of data, space-separate them. Same as
3030
\fB-S " "\fP.
3131
.TP
32+
\fB-P pragma=value\fP
33+
Set a pragma on the command line. Multiple \fB-P\fP options can be
34+
specified to set multiple pragmas.
35+
.TP
3236
\fB-V\fP
3337
Be verbose when importing data.
3438
.TP

test/test_admin.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1510,18 +1510,15 @@ def testSpecification(self):
15101510
self.assertEqual(sorted(outlist), sorted(spec))
15111511

15121512
# -----
1513-
inputs = iter(["pragma display_protected=1", "spec user", "quit"])
1514-
AdminTool.my_input = lambda _self, _prompt: next(inputs)
1515-
15161513
self.install_init()
15171514
self.admin=AdminTool()
1518-
sys.argv=['main', '-i', self.dirname]
15191515

15201516
with captured_output() as (out, err):
1517+
sys.argv=['main', '-i', self.dirname, '-P',
1518+
'display_protected=1', 'specification', 'user']
15211519
ret = self.admin.main()
15221520

1523-
# strip greeting and help text lines
1524-
outlist = out.getvalue().strip().split('\n')[2:]
1521+
outlist = out.getvalue().strip().split('\n')
15251522

15261523
protected = [ 'id: <roundup.hyperdb.String>',
15271524
'creation: <roundup.hyperdb.Date>',

0 commit comments

Comments
 (0)