Add version command line
This commit is contained in:
@@ -15,6 +15,7 @@ class OptAction(IntEnum):
|
||||
RESTORE = 1
|
||||
LIST = 2
|
||||
LIST_LEVELDB_KEY = 3
|
||||
VERSION = 4
|
||||
|
||||
@staticmethod
|
||||
def from_str(v: str) -> IntEnum:
|
||||
@@ -28,6 +29,8 @@ class OptAction(IntEnum):
|
||||
return OptAction.LIST
|
||||
elif t == 'list_leveldb_key':
|
||||
return OptAction.LIST_LEVELDB_KEY
|
||||
elif t == "version":
|
||||
return OptAction.VERSION
|
||||
else:
|
||||
raise TypeError('Must be str.')
|
||||
|
||||
@@ -59,7 +62,7 @@ class Opts:
|
||||
re = OptAction.from_str(cm[0])
|
||||
if re is not None:
|
||||
self.action = re
|
||||
if re == OptAction.LIST:
|
||||
if re == OptAction.LIST or re == OptAction.VERSION:
|
||||
return
|
||||
elif re == OptAction.LIST_LEVELDB_KEY:
|
||||
if len(cm) == 1:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from game_backuper.config import Config
|
||||
from game_backuper.cml import Opts
|
||||
from game_backuper.cml import Opts, OptAction
|
||||
from game_backuper.db import Db
|
||||
from game_backuper.backuper import Backuper
|
||||
from os import makedirs
|
||||
@@ -11,6 +11,28 @@ def main(cm=None):
|
||||
import sys
|
||||
cm = sys.argv[1:]
|
||||
cml = Opts(cm)
|
||||
if cml.action == OptAction.VERSION:
|
||||
from game_backuper.compress import (
|
||||
have_brotli,
|
||||
have_bz2,
|
||||
have_gzip,
|
||||
have_lzip,
|
||||
have_lzma,
|
||||
have_snappy,
|
||||
have_zstd,
|
||||
)
|
||||
from game_backuper.leveldb import have_leveldb
|
||||
from game_backuper.regexp import have_pcre2
|
||||
print("Brotli support:", have_brotli)
|
||||
print("BZip2 support:", have_bz2)
|
||||
print("GZip support:", have_gzip)
|
||||
print("LZip support:", have_lzip)
|
||||
print("LZMA support:", have_lzma)
|
||||
print("Snappy support:", have_snappy)
|
||||
print("ZSTD support:", have_zstd)
|
||||
print("LevelDB support:", have_leveldb)
|
||||
print("PCRE2 support:", have_pcre2)
|
||||
return 0
|
||||
cfg = Config(cml.config_file)
|
||||
if not exists(cfg.dest):
|
||||
makedirs(cfg.dest)
|
||||
|
||||
Reference in New Issue
Block a user