mirror of
https://github.com/borgbackup/borg.git
synced 2025-01-03 05:35:58 +00:00
Merge pull request #6108 from sophie-h/sophie-h/list-command-line
list: Add command_line to format keys
This commit is contained in:
commit
5edc773488
2 changed files with 12 additions and 2 deletions
|
@ -1148,7 +1148,7 @@ _borg_format_keys() {
|
|||
local repo_or_arch=${(Q)1}
|
||||
|
||||
local -a keys=( NEWLINE NL NUL SPACE TAB CR LF )
|
||||
local -a repository_keys=( archive name barchive comment bcomment id start time end hostname username )
|
||||
local -a repository_keys=( archive name barchive comment bcomment id start time end command_line hostname username )
|
||||
local -a archive_keys=( type mode uid gid user group path bpath source linktarget flags size csize dsize dcsize
|
||||
num_chunks unique_chunks mtime ctime atime isomtime isoctime isoatime blake2b blake2s md5 sha1 sha224 sha256 sha384
|
||||
sha3_224 sha3_256 sha3_384 sha3_512 sha512 shake_128 shake_256 archiveid archivename extra health )
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
import os
|
||||
import os.path
|
||||
import re
|
||||
import shlex
|
||||
import socket
|
||||
import stat
|
||||
import uuid
|
||||
|
@ -567,13 +568,14 @@ class ArchiveFormatter(BaseFormatter):
|
|||
'start': 'time (start) of creation of the archive',
|
||||
'time': 'alias of "start"',
|
||||
'end': 'time (end) of creation of the archive',
|
||||
'command_line': 'command line which was used to create the archive',
|
||||
'id': 'internal ID of the archive',
|
||||
'hostname': 'hostname of host on which this archive was created',
|
||||
'username': 'username of user who created this archive',
|
||||
}
|
||||
KEY_GROUPS = (
|
||||
('archive', 'name', 'barchive', 'comment', 'bcomment', 'id'),
|
||||
('start', 'time', 'end'),
|
||||
('start', 'time', 'end', 'command_line'),
|
||||
('hostname', 'username'),
|
||||
)
|
||||
|
||||
|
@ -624,6 +626,7 @@ def __init__(self, format, repository, manifest, key, *, json=False, iec=False):
|
|||
'comment': partial(self.get_meta, 'comment', rs=True),
|
||||
'bcomment': partial(self.get_meta, 'comment', rs=False),
|
||||
'end': self.get_ts_end,
|
||||
'command_line': self.get_cmdline,
|
||||
}
|
||||
self.used_call_keys = set(self.call_keys) & self.format_keys
|
||||
if self.json:
|
||||
|
@ -664,6 +667,13 @@ def get_meta(self, key, rs):
|
|||
value = self.archive.metadata.get(key, '')
|
||||
return remove_surrogates(value) if rs else value
|
||||
|
||||
def get_cmdline(self):
|
||||
cmdline = map(remove_surrogates, self.archive.metadata.get('cmdline', []))
|
||||
if self.json:
|
||||
return list(cmdline)
|
||||
else:
|
||||
return ' '.join(map(shlex.quote, cmdline))
|
||||
|
||||
def get_ts_end(self):
|
||||
return self.format_time(self.archive.ts_end)
|
||||
|
||||
|
|
Loading…
Reference in a new issue