From 8e0cb30d0a899afc0b0528ab46b7aa503c003598 Mon Sep 17 00:00:00 2001 From: JustAnotherArchivist Date: Tue, 20 Oct 2020 17:29:58 +0000 Subject: [PATCH] Add atdash mode --- archivebot-jobs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/archivebot-jobs b/archivebot-jobs index 850130d..02c611c 100755 --- a/archivebot-jobs +++ b/archivebot-jobs @@ -105,12 +105,13 @@ parser.add_argument('--filter', '-f', nargs = 1, type = str, action = FilterActi parser.add_argument('--ifilter', '-i', nargs = 1, type = str, action = FilterAction, dest = 'filter', help = 'Like --filter but case-insensitive') parser.add_argument('--pyfilter', nargs = 1, type = str, action = FilterAction, dest = 'filter', help = 'A Python expression for filtering using the local variable `job`') parser.add_argument('--sort', '-s', nargs = 1, type = str, action = SortAction, help = "Sort the table by a COLUMN (descending if preceded by '-'). This can be used multiple times to refine the sorting.") -parser.add_argument('--mode', choices = ('table', 'dashboard-regex', 'con-d-commands', 'format'), default = 'table', help = '\n'.join([ +parser.add_argument('--mode', choices = ('table', 'dashboard-regex', 'con-d-commands', 'format', 'atdash'), default = 'table', help = '\n'.join([ 'Output modes:', ' table: print a table of the matched jobs', ' dashboard-regex: compose a regular expression that can be used on the dashboard to actively watch the jobs matched by the filter', ' con-d-commands: print !con and !d commands for the current settings', ' format: print some output for each job, separated by newlines; this requires the --format option', + ' atdash: print the URL for displaying the matched jobs on atdash', ])) parser.add_argument('--no-colours', '--no-colors', action = 'store_true', help = "Don't colourise the last activity column if it's been a while. (Table mode only)") parser.add_argument('--no-table', action = 'store_true', help = 'Raw output without feeding through column(1); columns are separated by tabs. (Table mode only)') @@ -200,6 +201,9 @@ elif args.mode == 'format': for job in jobs: print(args.format.format(**{key.replace(' ', '_'): value for key, value in job.items()})) sys.exit(0) +elif args.mode == 'atdash': + print('https://atdash.meo.ws/d/nipgvEwmk/archivebot?orgId=1&' + '&'.join(f'var-ident={job["jobid"]}' for job in jobs)) + sys.exit(0) # Renderers def render_date(ts, coloured = False):